def add_string_helper(self, node, string, index): if string is None or index >= len(string): return None # terminating string or root if node is None: node = TrieNode('*') character = string[index] children = node.get_children() if character not in node.get_children(): #print("adding new node", character, "root node", node.get_char()) children[character] = TrieNode(character) new_node = self.add_string_helper(children[character], string, index+1) if new_node is not None: node.add_children(character, new_node) return node