@Override
    public boolean hasNext() {
        try {
            while (true) {
                if (this.edgeIterator.hasNext())
                    return true;
                if (this.readers.isEmpty())
                    return false;
                if (this.readers.peek().nextKeyValue()) {
                    this.edgeIterator = this.readers.peek().getCurrentValue().get().edges(Direction.OUT);
                } else {
                    this.readers.remove().close();
                }
            }
        } catch (final Exception e) {
            throw new IllegalStateException(e.getMessage(), e);
        }
    }
@author Marko A. Rodriguez (http://markorodriguez.com)
hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/HadoopEdgeIterator.java