So finally I realized the proper way in gremlin should be:
g.v(A.id).as('x').copySplit(_().out('impacts'), _().both('similarTo')).fairMerge.loop('x'){it.loops < 4}{true}
But there is the bug in gremlin at the moment (see bug report) and copySplit doesn't work well with loop. Anyway I had to add ._() before copySplit to make it working:
g.v(A.id).as('x')._().copySplit(_().out('impacts'), _().both('similarTo')).fairMerge.loop('x'){it.loops < 4}{true}