title: Trie implementation in Python
body: <p>I tried to make this implementation clear. So I created <code>hasChild</code> function of <code>Node</code>. But why am I getting this this error?</p>
  
  <blockquote>
    <p>'NoneType' object has no attribute 'hasChild'</p>
  </blockquote>
  
  <pre><code>class Node():
      def __init__(self,word):
          self.value = str(word)
          self.children = {}   
          self.isEndOfWord = False
  
      def hasChild(self,ch):
          return ch in self.children.keys()
  
      def addChild(self,ch):
          nodenew = Node(str(ch))
          self.children[ch] = nodenew
  
      def getChild(self,ch):
          return self.children.get(ch)
  
  class Trie():
      def __init__(self):
          self.root = Node('')
  
      def insert(self,children):
          current = self.root
          for ch in children:
              if (current.hasChild(ch) is False):
                  current.addChild(ch)
              current = self.root.getChild(ch)
          current.isEndOfWord = True
  </code></pre>