text: public static List<? extends Tree> getAncestors(Tree t) {if ( t.getParent()==null ) return Collections.emptyList();List<Tree> ancestors = new ArrayList<Tree>();t = t.getParent();while ( t!=null ) {ancestors.add(0, t); t = t.getParent();}return ancestors;}