@ SuppressWarnings ( "unchecked" ) public < T extends WindupVertexFrame > Iterable < T > findVariableOfType ( Class < T > type ) { for ( Map < String , Iterable < ? extends WindupVertexFrame > > topOfStack : deque ) { for ( Iterable < ? extends WindupVertexFrame > frames : topOfStack . values ( ) ) { boolean empty = true ; for ( WindupVertexFrame frame : frames ) { if ( ! type . isAssignableFrom ( frame . getClass ( ) ) ) { break ; } else { empty = false ; } } // now we know all the frames are of the chosen type if ( ! empty ) return ( Iterable < T > ) frames ; } } return null ; }
Searches the variables layers top to bottom for the iterable having all of it s items of the given type . Return null if not found .