public CommonTree getFirstDescendantWithType(int type) {
        if ( getType()==type ) return this;
        if ( children==null ) return null;
        for (Object c : children) {
            GrammarAST t = (GrammarAST)c;
            if ( t.getType()==type ) return t;
            CommonTree d = t.getFirstDescendantWithType(type);
            if ( d!=null ) return d;
        }
        return null;
    }
Walk ancestors of this node until we find ALT with
 alt!=null or leftRecursiveAltInfo!=null. Then grab label if any.
 If not a rule element, just returns null.
tool/src/org/antlr/v4/tool/ast/GrammarAST.java