private void getRootNodeWithValidASTStr () {

    if (rootNode != null && rootNode.parent == null &&
        rootNode.hasValidMemoizedString()) {
      return;
    }
    ASTNode retNode = this;
    while (retNode.parent != null) {
      retNode = (ASTNode) retNode.parent;
    }
    rootNode=retNode;
    if (!rootNode.isValidASTStr) {
      rootNode.astStr = new StringBuilder();
      rootNode.toStringTree(rootNode);
      rootNode.isValidASTStr = true;
    }
    return;
  }
Tag this ASTNode with information about the object from which this node
originated.
parser/src/java/org/apache/hadoop/hive/ql/parse/ASTNode.java