@ GuardedBy ( "monitor" ) private /*@Nullable*/ TreeNode findNode ( /*@Nullable*/ String path ) { if ( Strings . isNullOrEmpty ( path ) || "/" . equals ( path ) ) { // Go back to the root directory. return root ; } else { List < String > dirs = PATH_SPLITTER . splitToList ( path ) ; TreeNode node = root ; for ( int i = 0 ; i < dirs . size ( ) ; i ++ ) { String dir = dirs . get ( i ) ; if ( "" . equals ( dir ) && i == 0 ) { continue ; // Skip the first "", the path of root node. } if ( ! node . children . containsKey ( dir ) ) { return null ; } else { node = node . children . get ( dir ) ; } } return node ; } }
Returns null if such a TreeNode doesn t exist .