      "            root.right = insert(root.right, data)\n",
      "            root.right.parent = root\n",
      "            return root.right\n",
      "        else:\n",
      "            return insert(root.right, data)"
     ]
    },
    {
     "cell_type": "code",
     "execution_count": 2,
 
</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     "def insert(root, data):\n",
    "    # TODO: Implement me\n",
    "    pass"
 </s> add     "class Bst(object):\n",
    "\n",
    "    def insert(self, data):\n",
    "        # TODO: Implement me\n",
    "        pass" </s> remove 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
 </s> add 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) </s> remove     "    test.test_tree()\n",
 </s> add     "    test.test_tree_one()\n",
    "    test.test_tree_two()\n",
    "            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)"
      "            root.right = insert(root.right, data)\n",
      "            root.right.parent = root\n",
      "            return root.right\n",
      "        else:\n",
    "            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)"
     ]
    },
    {
     "cell_type": "code",
     "execution_count": 2,
keep keep keep keep replace keep keep keep keep keep
 Move bst to a class 
graphs_trees/bst/bst_solution.ipynb