title: Binary Search Tree, Logical and Syntax Error
body: <p>I am trying to implement a binary search tree, But I think I did a logical and syntax error, brain fart now.</p>
  
  <p>I Implemented the basic operations following a Pseudo code I have (I cannot refactor the code). What I have implemented so far is class find, findMax, Insert, Traverse, But looks like I am doing a logical mistake somewhere, any help ?</p>
  
  <pre><code>#!/usr/bin/python3.6
  
  class Node:
    def __init__(self, key=None):
      self.key = key
      self.left = None
      self.right = None
  
  class BST:
    root = Node()
  
    def find0(self, key):
      x =  self.find(self.root, key)
      return x
  
    # Recusive
    def find(self, root, key):
      if root is None or key == self.root.key:
        return self.root
      elif key &gt; self.root.key:
        return self.find(self.root.right, key)
      else:
        return self.find(self.root.left, key)
  
    def findMin0():
      FNode = self.findMin(self.root)
      return FNode
  
    # Recursive
    def findMin(self, root):
      if self.root.right is None:
        return self.root
      else:
        return findMin(self.root.left)
  
   def findMax0():
      FNode = findMin(self.root)
      return FNode
  
    # Recursive
    def findMax(self, root):
      if self.root.right is None:
        return self.root
      else:
        return findMin(self.root.left)
  
    def insert(self, data):
      self.root = self.insertInTree(self.root, data)
  
    def insertInTree(self, root, key):
      if root.left is None and root.right is None :
         root = Node(key)
         return root
      elif key &lt; root.key:
         root.left = self.insertInTree(root.left, key)
      elif key &gt; root.key:
         root.right = self.insertInTree(root.right, key)
      return root
  
    def traverseInOrder0(self):
      self.traverseInOrder(self.root)
  
    def traverseInOrder(self, root):
      if root.key is not None:
        self.traverseInOrder(root.left)
        self.visit(root)
        self.traverseInOrder(root.right)
  
    def visit(self, node):
      print (node.key)
  
    def getRoot():
      return root
  
  def main():
    NewTree = BST()
    NewTree.insert(100)
    NewTree.insert(90)
    NewTree.insert(110)
    NewTree.traverseInOrder0()
    #NewTree.findMin()
  
  
  if __name__ == "__main__":
    main()
  </code></pre>
  
  <p>As of now, I can see the following errors</p>
  
  <pre><code>Traceback (most recent call last):  
    File "./bst", line 86, in &lt;module&gt;  
      main()  
    File "./bst", line 81, in main  
      NewTree.traverseInOrder0()  
    File "./bst", line 61, in traverseInOrder0  
      self.traverseInOrder(self.root)  
    File "./bst", line 65, in traverseInOrder  
      self.traverseInOrder(root.left)  
    File "./bst", line 64, in traverseInOrder  
      if root.key is not None:  
  AttributeError: 'NoneType' object has no attribute 'key'
  </code></pre>