public static void stripChildrenOutOfRange(ParserRuleContext t,
											   ParserRuleContext root,
											   int startIndex,
											   int stopIndex)
	{
		if ( t==null ) return;
		for (int i = 0; i < t.getChildCount(); i++) {
			ParseTree child = t.getChild(i);
			Interval range = child.getSourceInterval();
			if ( child instanceof ParserRuleContext && (range.b < startIndex || range.a > stopIndex) ) {
				if ( isAncestorOf(child, root) ) { // replace only if subtree doesn't have displayed root
					CommonToken abbrev = new CommonToken(Token.INVALID_TYPE, "...");
					t.children.set(i, new TerminalNodeImpl(abbrev));
				}
			}
		}
	}
Replace any subtree siblings of root that are completely to left
 or right of lookahead range with a CommonToken(Token.INVALID_TYPE,"...")
 node. The source interval for t is not altered to suit smaller range!

 WARNING: destructive to t.

 @since 4.5.1
runtime/Java/src/org/antlr/v4/runtime/tree/Trees.java