@ SuppressWarnings ( "unchecked" ) public < T extends ElementBase > T getAncestor ( Class < T > clazz ) { ElementBase parent = getParent ( ) ; while ( parent != null && ! clazz . isInstance ( parent ) ) { parent = parent . getParent ( ) ; } return ( T ) parent ; }
Returns the first ancestor corresponding to the specified class .