public List<GrammarAST> getNodesWithType(IntervalSet types) {
		List<GrammarAST> nodes = new ArrayList<GrammarAST>();
		List<GrammarAST> work = new LinkedList<GrammarAST>();
		work.add(this);
		GrammarAST t;
		while ( !work.isEmpty() ) {
			t = work.remove(0);
			if ( types==null || types.contains(t.getType()) ) nodes.add(t);
			if ( t.children!=null ) {
				work.addAll(Arrays.asList(t.getChildrenAsArray()));
			}
		}
		return nodes;
	}
If we build an ATN, we make AST node point at left edge of ATN construct
tool/src/org/antlr/v4/tool/ast/GrammarAST.java