question: public static < T extends Tree > T enclosingOfClass ( final TreePath path , final Class < T > treeClass ) { TreePath p = path ; while ( p != null ) { Tree leaf = p . getLeaf ( ) ; if ( treeClass . isInstance ( leaf ) ) { return treeClass . cast ( leaf ) ; } p = p . getParentPath ( ) ; } return null ; }
target:  Gets the first enclosing tree in path, of the specified class