Need to use a new visitor here like we discussed way back when. The NextSequenceValueParseNode may be used inside of a nested expression, potentially many levels down. A visitor traverses down all these levels, where as this only looks at the top level. You'll want a new visitor class, derived from TraverseAllParseNodeVisitor (which by default traverses the entire tree if you don't override any of the methods). In your NextSequenceParseNodeVisitor, you'll specialize the following method:

    public Void visit(NextSequenceValueParseNode node) throws SQLException

This is your "callback". You'll have a member variable in your visitor:

    private final List<NextSequenceValueParseNode> nextSequenceParseNodes = Lists.newArrayList();

Just add each node to this list, and after the accept call, the visitor will have a list of all the next sequence nodes in an expression. The order is deterministic, so you can count on this and not even need to later use a Map to replace them with their resolved constants you get back from your server call.