      def __repr__(self):
          return str(self.data)
  
  
  def insert(root, data):
      # Constraint: Assume we are working with valid ints
      if root is None:
          root = Node(data)
          return root
      if data <= root.data:
          if root.left is None:
              root.left = insert(root.left, data)
              root.left.parent = root
              return root.left
          else:
              return insert(root.left, data)
      else:
          if root.right is None:
              root.right = insert(root.right, data)
              root.right.parent = root
              return root.right
          else:
              return insert(root.right, data) 
</s> remove     "def insert(root, data):\n",
    "    # Constraint: Assume we are working with valid ints\n",
    "    if root is None:\n",
    "        root = Node(data)\n",
    "        return root\n",
    "    if data <= root.data:\n",
    "        if root.left is None:\n",
    "            root.left = insert(root.left, data)\n",
    "            root.left.parent = root\n",
    "            return root.left\n",
    "        else:\n",
    "            return insert(root.left, data)\n",
    "    else:\n",
    "        if root.right is None:\n",
    "            root.right = insert(root.right, data)\n",
    "            root.right.parent = root\n",
    "            return root.right\n",
 </s> add     "class Bst(object):\n",
    "\n",
    "    def __init__(self, root=None):\n",
    "        self.root = root\n",
    "\n",
    "    def insert(self, data):\n",
    "        if data is None:\n",
    "            raise Exception('Data cannot be None')\n",
    "        if self.root is None:\n",
    "            self.root = Node(data)\n",
    "            return self.root\n",
    "        return self._insert(self.root, data)\n",
    "\n",
    "    def _insert(self, node, data):\n",
    "        # Constraint: Assume we are working with valid ints\n",
    "        if node is None:\n",
    "            return Node(data)\n",
    "        if data <= node.data:\n",
    "            if node.left is None:\n",
    "                node.left = self._insert(node.left, data)\n",
    "                node.left.parent = node\n",
    "                return node.left\n",
    "            else:\n",
    "                return self._insert(node.left, data)\n", </s> remove             return insert(root.right, data) </s> add  </s> remove     "            return insert(root.right, data)"
 </s> add     "            if node.right is None:\n",
    "                node.right = self._insert(node.right, data)\n",
    "                node.right.parent = node\n",
    "                return node.right\n",
    "            else:\n",
    "                return self._insert(node.right, data)" </s> remove     test.test_tree()
 </s> add     test.test_tree_one()
    test.test_tree_two() </s> remove     def test_tree(self):
        node = Node(5)
        assert_equal(insert(node, 2).data, 2)
        assert_equal(insert(node, 8).data, 8)
        assert_equal(insert(node, 1).data, 1)
        assert_equal(insert(node, 3).data, 3)
        in_order_traversal(node, self.results.add_result)
 </s> add     def test_tree_one(self):
        bst = Bst()
        bst.insert(5)
        bst.insert(2)
        bst.insert(8)
        bst.insert(1)
        bst.insert(3)
        in_order_traversal(bst.root, self.results.add_result)
class Bst(object):

    def __init__(self, root=None):
        self.root = root

    def insert(self, data):
        if data is None:
            raise Exception('Data cannot be None')
        if self.root is None:
            self.root = Node(data)
            return self.root
        return self._insert(self.root, data)

    def _insert(self, node, data):
        # Constraint: Assume we are working with valid ints
        if node is None:
            return Node(data)
        if data <= node.data:
            if node.left is None:
                node.left = self._insert(node.left, data)
                node.left.parent = node
                return node.left
            else:
                return self._insert(node.left, data)
      def __repr__(self):
          return str(self.data)
  
  
class Bst(object):

    def __init__(self, root=None):
        self.root = root

    def insert(self, data):
        if data is None:
            raise Exception('Data cannot be None')
        if self.root is None:
            self.root = Node(data)
            return self.root
        return self._insert(self.root, data)

    def _insert(self, node, data):
        # Constraint: Assume we are working with valid ints
        if node is None:
            return Node(data)
        if data <= node.data:
            if node.left is None:
                node.left = self._insert(node.left, data)
                node.left.parent = node
                return node.left
            else:
                return self._insert(node.left, data)
class Bst(object):

    def __init__(self, root=None):
        self.root = root

    def insert(self, data):
        if data is None:
            raise Exception('Data cannot be None')
        if self.root is None:
            self.root = Node(data)
            return self.root
        return self._insert(self.root, data)

    def _insert(self, node, data):
        # Constraint: Assume we are working with valid ints
        if node is None:
            return Node(data)
        if data <= node.data:
            if node.left is None:
                node.left = self._insert(node.left, data)
                node.left.parent = node
                return node.left
            else:
                return self._insert(node.left, data)
class Bst(object):

    def __init__(self, root=None):
        self.root = root

    def insert(self, data):
        if data is None:
            raise Exception('Data cannot be None')
        if self.root is None:
            self.root = Node(data)
            return self.root
        return self._insert(self.root, data)

    def _insert(self, node, data):
        # Constraint: Assume we are working with valid ints
        if node is None:
            return Node(data)
        if data <= node.data:
            if node.left is None:
                node.left = self._insert(node.left, data)
                node.left.parent = node
                return node.left
            else:
                return self._insert(node.left, data)
class Bst(object):

    def __init__(self, root=None):
        self.root = root

    def insert(self, data):
        if data is None:
            raise Exception('Data cannot be None')
        if self.root is None:
            self.root = Node(data)
            return self.root
        return self._insert(self.root, data)

    def _insert(self, node, data):
        # Constraint: Assume we are working with valid ints
        if node is None:
            return Node(data)
        if data <= node.data:
            if node.left is None:
                node.left = self._insert(node.left, data)
                node.left.parent = node
                return node.left
            else:
                return self._insert(node.left, data)
class Bst(object):

    def __init__(self, root=None):
        self.root = root

    def insert(self, data):
        if data is None:
            raise Exception('Data cannot be None')
        if self.root is None:
            self.root = Node(data)
            return self.root
        return self._insert(self.root, data)

    def _insert(self, node, data):
        # Constraint: Assume we are working with valid ints
        if node is None:
            return Node(data)
        if data <= node.data:
            if node.left is None:
                node.left = self._insert(node.left, data)
                node.left.parent = node
                return node.left
            else:
                return self._insert(node.left, data)
class Bst(object):

    def __init__(self, root=None):
        self.root = root

    def insert(self, data):
        if data is None:
            raise Exception('Data cannot be None')
        if self.root is None:
            self.root = Node(data)
            return self.root
        return self._insert(self.root, data)

    def _insert(self, node, data):
        # Constraint: Assume we are working with valid ints
        if node is None:
            return Node(data)
        if data <= node.data:
            if node.left is None:
                node.left = self._insert(node.left, data)
                node.left.parent = node
                return node.left
            else:
                return self._insert(node.left, data)
class Bst(object):

    def __init__(self, root=None):
        self.root = root

    def insert(self, data):
        if data is None:
            raise Exception('Data cannot be None')
        if self.root is None:
            self.root = Node(data)
            return self.root
        return self._insert(self.root, data)

    def _insert(self, node, data):
        # Constraint: Assume we are working with valid ints
        if node is None:
            return Node(data)
        if data <= node.data:
            if node.left is None:
                node.left = self._insert(node.left, data)
                node.left.parent = node
                return node.left
            else:
                return self._insert(node.left, data)
class Bst(object):

    def __init__(self, root=None):
        self.root = root

    def insert(self, data):
        if data is None:
            raise Exception('Data cannot be None')
        if self.root is None:
            self.root = Node(data)
            return self.root
        return self._insert(self.root, data)

    def _insert(self, node, data):
        # Constraint: Assume we are working with valid ints
        if node is None:
            return Node(data)
        if data <= node.data:
            if node.left is None:
                node.left = self._insert(node.left, data)
                node.left.parent = node
                return node.left
            else:
                return self._insert(node.left, data)
class Bst(object):

    def __init__(self, root=None):
        self.root = root

    def insert(self, data):
        if data is None:
            raise Exception('Data cannot be None')
        if self.root is None:
            self.root = Node(data)
            return self.root
        return self._insert(self.root, data)

    def _insert(self, node, data):
        # Constraint: Assume we are working with valid ints
        if node is None:
            return Node(data)
        if data <= node.data:
            if node.left is None:
                node.left = self._insert(node.left, data)
                node.left.parent = node
                return node.left
            else:
                return self._insert(node.left, data)
class Bst(object):

    def __init__(self, root=None):
        self.root = root

    def insert(self, data):
        if data is None:
            raise Exception('Data cannot be None')
        if self.root is None:
            self.root = Node(data)
            return self.root
        return self._insert(self.root, data)

    def _insert(self, node, data):
        # Constraint: Assume we are working with valid ints
        if node is None:
            return Node(data)
        if data <= node.data:
            if node.left is None:
                node.left = self._insert(node.left, data)
                node.left.parent = node
                return node.left
            else:
                return self._insert(node.left, data)
class Bst(object):

    def __init__(self, root=None):
        self.root = root

    def insert(self, data):
        if data is None:
            raise Exception('Data cannot be None')
        if self.root is None:
            self.root = Node(data)
            return self.root
        return self._insert(self.root, data)

    def _insert(self, node, data):
        # Constraint: Assume we are working with valid ints
        if node is None:
            return Node(data)
        if data <= node.data:
            if node.left is None:
                node.left = self._insert(node.left, data)
                node.left.parent = node
                return node.left
            else:
                return self._insert(node.left, data)
class Bst(object):

    def __init__(self, root=None):
        self.root = root

    def insert(self, data):
        if data is None:
            raise Exception('Data cannot be None')
        if self.root is None:
            self.root = Node(data)
            return self.root
        return self._insert(self.root, data)

    def _insert(self, node, data):
        # Constraint: Assume we are working with valid ints
        if node is None:
            return Node(data)
        if data <= node.data:
            if node.left is None:
                node.left = self._insert(node.left, data)
                node.left.parent = node
                return node.left
            else:
                return self._insert(node.left, data)
class Bst(object):

    def __init__(self, root=None):
        self.root = root

    def insert(self, data):
        if data is None:
            raise Exception('Data cannot be None')
        if self.root is None:
            self.root = Node(data)
            return self.root
        return self._insert(self.root, data)

    def _insert(self, node, data):
        # Constraint: Assume we are working with valid ints
        if node is None:
            return Node(data)
        if data <= node.data:
            if node.left is None:
                node.left = self._insert(node.left, data)
                node.left.parent = node
                return node.left
            else:
                return self._insert(node.left, data)
class Bst(object):

    def __init__(self, root=None):
        self.root = root

    def insert(self, data):
        if data is None:
            raise Exception('Data cannot be None')
        if self.root is None:
            self.root = Node(data)
            return self.root
        return self._insert(self.root, data)

    def _insert(self, node, data):
        # Constraint: Assume we are working with valid ints
        if node is None:
            return Node(data)
        if data <= node.data:
            if node.left is None:
                node.left = self._insert(node.left, data)
                node.left.parent = node
                return node.left
            else:
                return self._insert(node.left, data)
class Bst(object):

    def __init__(self, root=None):
        self.root = root

    def insert(self, data):
        if data is None:
            raise Exception('Data cannot be None')
        if self.root is None:
            self.root = Node(data)
            return self.root
        return self._insert(self.root, data)

    def _insert(self, node, data):
        # Constraint: Assume we are working with valid ints
        if node is None:
            return Node(data)
        if data <= node.data:
            if node.left is None:
                node.left = self._insert(node.left, data)
                node.left.parent = node
                return node.left
            else:
                return self._insert(node.left, data)
class Bst(object):

    def __init__(self, root=None):
        self.root = root

    def insert(self, data):
        if data is None:
            raise Exception('Data cannot be None')
        if self.root is None:
            self.root = Node(data)
            return self.root
        return self._insert(self.root, data)

    def _insert(self, node, data):
        # Constraint: Assume we are working with valid ints
        if node is None:
            return Node(data)
        if data <= node.data:
            if node.left is None:
                node.left = self._insert(node.left, data)
                node.left.parent = node
                return node.left
            else:
                return self._insert(node.left, data)
class Bst(object):

    def __init__(self, root=None):
        self.root = root

    def insert(self, data):
        if data is None:
            raise Exception('Data cannot be None')
        if self.root is None:
            self.root = Node(data)
            return self.root
        return self._insert(self.root, data)

    def _insert(self, node, data):
        # Constraint: Assume we are working with valid ints
        if node is None:
            return Node(data)
        if data <= node.data:
            if node.left is None:
                node.left = self._insert(node.left, data)
                node.left.parent = node
                return node.left
            else:
                return self._insert(node.left, data)
          else:
              return insert(root.right, data) 
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep
 Move bst to a class 
graphs_trees/bst/bst.py