title: Trie implementation in Java
body: <p>This is my implementation of a Trie. </p>
  
  <pre><code>public class Trie {
  
      private class Node{
          private Map&lt;Character, Node&gt; children;
          boolean end;
  
          public Node(){
              children = new HashMap&lt;&gt;();
              end = false;
          }
      }
  
      private Node root;
  
      public Trie(){
          root = new Node();
      }
  
      public void insert(String word){
          Node current = root;
          for (int i=0; i &lt; word.length(); i++){
              char c = word.charAt(i);
              Node node = current.children.get(c);
              if(node == null){
                  node = new Node();
                  current.children.put(c, node);
              }
              current = node;
          }
      }
  
      public boolean search(String word){
          Node current = root;
          for(int i =0; i &lt; word.length(); i++){
              char c = word.charAt(i);
              Node node = current.children.get(c);
              if(node == null) 
                  return false;
              current = node;
          }
          return current.end;
      }
  }
  </code></pre>
  
  <p>I want to add a method, that given a string return all its children, something that could be used as a real world autocorrect suggestions. </p>
  
  <p>Here's the method signature:</p>
  
  <pre><code>public List&lt;String&gt; returnAllChildren(String str){
  
  }
  </code></pre>
  
  <p>I'm a little lost with this one. Any help appreciated.</p>