public static Iterator<TinkerVertex> getVerticesTx(final TinkerVertex vertex, final Direction direction, final String... edgeLabels) {
        final Set<Object> inEdgesIds = new HashSet<>();
        if (direction.equals(Direction.OUT) || direction.equals(Direction.BOTH)) {
            if (vertex.outEdgesId != null) {
                if (edgeLabels.length == 0)
                    vertex.outEdgesId.values().forEach(set -> set.forEach(edge -> inEdgesIds.add(edge)));
                else if (edgeLabels.length == 1)
                    vertex.outEdgesId.getOrDefault(edgeLabels[0], Collections.emptySet()).forEach(edge -> inEdgesIds.add(edge));
                else
                    Stream.of(edgeLabels).map(vertex.outEdgesId::get).filter(Objects::nonNull).flatMap(Set::stream).forEach(edge -> inEdgesIds.add(edge));
            }
        }
        final Set<Object> outEdgesIds = new HashSet<>();
        if (direction.equals(Direction.IN) || direction.equals(Direction.BOTH)) {
            if (vertex.inEdgesId != null) {
                if (edgeLabels.length == 0)
                    vertex.inEdgesId.values().forEach(set -> set.forEach(edge -> outEdgesIds.add(edge)));
                else if (edgeLabels.length == 1)
                    vertex.inEdgesId.getOrDefault(edgeLabels[0], Collections.emptySet()).forEach(edge -> outEdgesIds.add(edge));
                else
                    Stream.of(edgeLabels).map(vertex.inEdgesId::get).filter(Objects::nonNull).flatMap(Set::stream).forEach(edge -> outEdgesIds.add(edge));
            }
        }

        final List<Vertex> vertices = new ArrayList<>();
        if (inEdgesIds.size() != 0)
            vertex.graph().edges(inEdgesIds.toArray()).forEachRemaining(edge -> vertices.add(edge.inVertex()));
        if (outEdgesIds.size() != 0)
            vertex.graph().edges(outEdgesIds.toArray()).forEachRemaining(edge -> vertices.add(edge.outVertex()));

        return vertices.size() == 0
                ? Collections.emptyIterator()
                : vertices.stream().map(v -> (TinkerVertex) v).iterator();
    }
@author Marko A. Rodriguez (http://markorodriguez.com)
tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerHelper.java