title: Deleting a specific node from a tree
body: <p>Below is a program that I am working on involving trees. I am currently trying to be able to delete a specific node from created tree. Can someone offer some suggestions on what I am doing wrong? The code in question is def remove portion. The rest of it is working correctly.   </p>
  
  <pre><code>    def remove(self, value):
          if self.root and self.root.value == value:  # special case for removing the root
              self.root = self.root.delete()
              return
  
          else:  # general case, removing a child node of some parent
              parent = self.root
              while parent:
                  if value &lt; parent.value:
                      child = parent.left
                      if child and child.value == value:
                          parent.left = child.delete()
                          return
                      parent = child
                  else:
                      child = parent.right
                      if child and child.value == value:
                          parent.right = child.delete()
                          return
                      parent = child
  </code></pre>