@Override
    public Object visitQuery(final GremlinParser.QueryContext ctx){
        final int childCount = ctx.getChildCount();
        if (childCount <= 3) {
            final ParseTree firstChild = ctx.getChild(0);
            if (firstChild instanceof GremlinParser.TraversalSourceContext) {
                if (childCount == 1) {
                    // handle traversalSource
                    return gvisitor.visitTraversalSource((GremlinParser.TraversalSourceContext)firstChild).getGremlinLang();
                } else {
                    // handle traversalSource DOT transactionPart
                    throw new GremlinParserException("Transaction operation is not supported yet");
                }
            } else if (firstChild instanceof GremlinParser.EmptyQueryContext) {
                // handle empty query
                return "";
            } else {
                if (childCount == 1) {
                    // handle rootTraversal
                    return tvisitor.visitRootTraversal(
                            (GremlinParser.RootTraversalContext)firstChild).asAdmin().getGremlinLang();
                } else {
                    // handle rootTraversal DOT traversalTerminalMethod
                    // could not keep all of these methods in one visitor due to the need of the terminal visitor to have a traversal,
                    return new TerminalMethodToBytecodeVisitor(tvisitor
                            .visitRootTraversal((GremlinParser.RootTraversalContext)firstChild))
                            .visitTraversalTerminalMethod((GremlinParser.TraversalTerminalMethodContext)ctx.getChild(2));
                }
            }
        } else {
            // not clear what valid Gremlin, if any, will trigger this at the moment.
            throw new GremlinParserException("Unexpected parse tree for NoOpTerminalVisitor");
        }
    }
Returns {@link GremlinLang} of {@link Traversal} or {@link GraphTraversalSource}, overriding any terminal step
operations to prevent them from being executed using the {@link TraversalTerminalMethodVisitor} to append
terminal operations to GremlinLang.

@param ctx - the parse tree
@return - gremlinLang from the traversal or traversal source
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/grammar/NoOpTerminalVisitor.java