question: private static boolean matches ( TrieNode root , String str ) { int index = 0 ; while ( index < str . length ( ) ) { root = root . getChild ( str . charAt ( index ++ ) ) ; if ( root == null ) { break ; } else if ( root . exists ( ) ) { return true ; } } return false ; }
target:  Determines whether the given string is in the given trie. 