func TreesgetAncestors(t Tree) []Tree {
	ancestors := make([]Tree, 0)
	t = t.GetParent()
	for t != nil {
		f := []Tree{t}
		ancestors = append(f, ancestors...)
		t = t.GetParent()
	}
	return ancestors
}
Return a list of all ancestors of this node.  The first node of
list is the root and the last is the parent of this node.
package antlr
import "fmt"
func TreesStringTree(tree Tree, ruleNames []string, recog Recognizer) string {
	if recog != nil {
		ruleNames = recog.GetRuleNames()
	}
	s := TreesGetNodeText(tree, ruleNames, nil)
	s = EscapeWhitespace(s, false)
	c := tree.GetChildCount()
	if c == 0 {
		return s
	}
	res := "(" + s + " "
	if c > 0 {
		s = TreesStringTree(tree.GetChild(0), ruleNames, nil)
		res += s
	}
	for i := 1; i < c; i++ {
		s = TreesStringTree(tree.GetChild(i), ruleNames, nil)
		res += (" " + s)
	}
	res += ")"
	return res
}
func TreesGetNodeText(t Tree, ruleNames []string, recog Parser) string {
	if recog != nil {
		ruleNames = recog.GetRuleNames()
	}
	if ruleNames != nil {
		switch t2 := t.(type) {
		case RuleNode:
			t3 := t2.GetRuleContext()
			altNumber := t3.GetAltNumber()
			if altNumber != ATNInvalidAltNumber {
				return fmt.Sprintf("%s:%d", ruleNames[t3.GetRuleIndex()], altNumber)
			}
			return ruleNames[t3.GetRuleIndex()]
		case ErrorNode:
			return fmt.Sprint(t2)
		case TerminalNode:
			if t2.GetSymbol() != nil {
				return t2.GetSymbol().GetText()
			}
		}
	}
	payload := t.GetPayload()
	if p2, ok := payload.(Token); ok {
		return p2.GetText()
	}
	return fmt.Sprint(t.GetPayload())
}
func TreesGetChildren(t Tree) []Tree {
	list := make([]Tree, 0)
	for i := 0; i < t.GetChildCount(); i++ {
		list = append(list, t.GetChild(i))
	}
	return list
}