public static Iterator<TinkerEdge> getEdgesTx(final TinkerVertex vertex, final Direction direction, final String... edgeLabels) {
        final List<Object> outEdgeIds = new ArrayList<>();
        if (direction.equals(Direction.OUT) || direction.equals(Direction.BOTH)) {
            if (vertex.outEdgesId != null) {
                if (edgeLabels.length == 0)
                    vertex.outEdgesId.values().forEach(outEdgeIds::addAll);
                else if (edgeLabels.length == 1)
                    outEdgeIds.addAll(vertex.outEdgesId.getOrDefault(edgeLabels[0], Collections.emptySet()));
                else
                    Stream.of(edgeLabels).map(vertex.outEdgesId::get).filter(Objects::nonNull).forEach(outEdgeIds::addAll);
            }
        }

        final List<Object> inEdgeIds = new ArrayList<>();
        if (direction.equals(Direction.IN) || direction.equals(Direction.BOTH)) {
            if (vertex.inEdgesId != null) {
                if (edgeLabels.length == 0)
                    vertex.inEdgesId.values().forEach(inEdgeIds::addAll);
                else if (edgeLabels.length == 1)
                    inEdgeIds.addAll(vertex.inEdgesId.getOrDefault(edgeLabels[0], Collections.emptySet()));
                else
                    Stream.of(edgeLabels).map(vertex.inEdgesId::get).filter(Objects::nonNull).forEach(inEdgeIds::addAll);
            }
        }

        return outEdgeIds.size() == 0 && inEdgeIds.size() == 0
                ? Collections.emptyIterator()
                : Stream.concat(outEdgeIds.stream(), inEdgeIds.stream())
                    .map(id -> ((AbstractTinkerGraph) vertex.graph()).edge(id))
                    .filter(v -> v != null)
                    .map(v -> (TinkerEdge) v).iterator();
    }
@author Marko A. Rodriguez (http://markorodriguez.com)
tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerHelper.java