@Override
    public boolean hasNext() {
        if (EmptyTraverser.instance() != this.nextEnd)
            return true;
        else {
            try {
                while (true) {
                    if (Thread.interrupted()) throw new TraversalInterruptedException();
                    this.nextEnd = this.processNextStart();
                    if (this.nextEnd.bulk() > 0)
                        return true;
                    else
                        this.nextEnd = EmptyTraverser.instance();
                }
            } catch (final NoSuchElementException e) {
                return false;
            }
        }
    }
@author Marko A. Rodriguez (http://markorodriguez.com)
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/util/AbstractStep.java