private bool Remove(string word, Node node)
        {
            if (word == "")
            {
                if (node.isWord)
                {
                    node.isWord = false;
                }
                return(true);
            }

            bool removeFlag = false;
            char nextChar   = word[0];
            Node nextNode   = null;

            if (node.HasChild(nextChar))
            {
                if (word.Length > 0)
                {
                    nextNode   = node.GetChild(nextChar);
                    removeFlag = Remove(word.Substring(1), node.GetChild(nextChar));
                }
            }

            if (removeFlag && !nextNode.HasChildren() && !nextNode.isWord)
            {
                node.RemoveChild(nextChar);
                return(true);
            }
            return(false);
        }
 private Node GetOrCreateNextNode(Node current, char c)
 {
     if (!current.HasChild(c))
     {
         current.AddChild(c);
     }
     return(current.GetChild(c));
 }
        public List <string> AutoComplete(string word)
        {
            Node startNode = root;
            var  results   = new List <string>();

            foreach (var c in word)
            {
                if (startNode.HasChild(c))
                {
                    startNode = startNode.GetChild(c);
                }
                else
                {
                    return(results);
                }
            }
            return(AutoComplete(word, startNode, results));
        }