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;
}

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 ; }
determines whether the given string is in the given trie .
