public static Tree findNodeSuchThat(Tree t, Predicate<Tree> pred) {
		if ( pred.test(t) ) return t;

		if ( t==null ) return null;

		int n = t.getChildCount();
		for (int i = 0 ; i < n ; i++){
			Tree u = findNodeSuchThat(t.getChild(i), pred);
			if ( u!=null ) return u;
		}
		return null;
	}
Return first node satisfying the pred

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