code: public Optional<String> get(String input) {
          TrieNode currentNode = root;
          int i=0;
          for(char c: input.toCharArray()) {
              TrieNode nextNode = currentNode.getChildren().get(c);
              if(nextNode != null) {
                  i++;
                  currentNode=nextNode;
              } else {
                  if(i>0 && currentNode.isLeaf()) {
                      return Optional.of(input.substring(0, i));
                  }
              }
          }
          if(i>0 && currentNode.isLeaf()) {
              return Optional.of(input.substring(0, i));
          }
          return Optional.empty();
     }
docs: Return the longest matching prefix of the input string that was added to the trie.
  @param input a string
  @return Optional of longest matching prefix that was added to the trie