can you complete the followingcode please.
class TrieNode:
def __init__(self, leaf=False):
self.leaf = leaf
self.__children = {}
def addChild(self, letter, leaf=False):
self.__children[letter] = TrieNode(leaf)
return self.__children[letter]
def getChild(self, letter):
return self.__children.get(letter, None)
def getFirstChild(self):
“””
This function gets you the first child of this node
“””
return next(iter(self.__children.items()))
def insert_trie(root, word):
cur_node = root
for letter in word:
next_node = cur_node.getChild(letter)
if next_node is None:
next_node = cur_node.addChild(letter)
cur_node = next_node
cur_node.leaf = True
def autocomplete(root, word):
“””
This function should return None if word is not a prefix of anywords in the trie,
otherwise it should return any word in the trie