@Override
    public Object visitTraversalTerminalMethod_hasNext(final GremlinParser.TraversalTerminalMethod_hasNextContext ctx) {
        try {
            return traversal.hasNext();
        } finally {
            CloseableIterator.closeIterator(traversal);
        }
    }
{@inheritDoc}

Traversal terminal method has next step
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/grammar/TraversalTerminalMethodVisitor.java