public ASTNode simpleBreadthFirstSearchAny(ASTNode ast, int... tokens) {
      searchQueue.clear();
      searchQueue.add(ast);
      while (!searchQueue.isEmpty()) {
        ASTNode next = searchQueue.poll();
        for (int i = 0; i < tokens.length; ++i) {
          if (next.getType() == tokens[i]) {
            return next;
          }
        }
        for (int i = 0; i < next.getChildCount(); ++i) {
          searchQueue.add((ASTNode) next.getChild(i));
        }
      }
      return null;
    }
Performs breadth-first search of the AST for a nested set of tokens. Tokens
don't have to be each others' direct children, they can be separated by
layers of other tokens. For each token in the list, the first one found is
matched and there's no backtracking; thus, if AST has multiple instances of
some token, of which only one matches, it is not guaranteed to be found. We
use this for simple things. Not thread-safe - reuses searchQueue.
ql/src/java/org/apache/hadoop/hive/ql/parse/CalcitePlanner.java