code: def delete(self):
          
          # we'll have to manually run through all the nodes that are going
          # to be deleted and remove nodes from the list if an ancestor is
          # already getting removed, since that would be redundant
          removed = {}
          for node in self.order_by('depth', 'path'):
              found = False
              for depth in range(1, int(len(node.path) / node.steplen)):
                  path = node._get_basepath(node.path, depth)
                  if path in removed:
                      # we are already removing a parent of this node
                      # skip
                      found = True
                      break
              if not found:
                  removed[node.path] = node
  
          # ok, got the minimal list of nodes to remove...
          # we must also remove their children
          # and update every parent node's numchild attribute
          # LOTS OF FUN HERE!
          parents = {}
          toremove = []
          for path, node in removed.items():
              parentpath = node._get_basepath(node.path, node.depth - 1)
              if parentpath:
                  if parentpath not in parents:
                      parents[parentpath] = node.get_parent(True)
                  parent = parents[parentpath]
                  if parent and parent.numchild > 0:
                      parent.numchild -= 1
                      parent.save()
              if node.is_leaf():
                  toremove.append(Q(path=node.path))
              else:
                  toremove.append(Q(path__startswith=node.path))
  
          # Django will handle this as a SELECT and then a DELETE of
          # ids, and will deal with removing related objects
          if toremove:
              qset = get_result_class(self.model).objects.filter(reduce(operator.or_, toremove))
              super(MP_NodeQuerySet, qset).delete()
docs: Custom delete method, will remove all descendant nodes to ensure a
          consistent tree (no orphans)
  
          :returns: ``None``