code: def set_parent(self, node):
          
          self._parent = node
  
          if node is None:
              # detach from parent
              self._depth = 0
          else:
              self._depth = node.get_depth() + 1
docs: Attach node to its parent.
  
          Args:
              node: Parent node.
  
          Note:
              ``node`` can be ``None``. In that case, the node is detached from its previous parent.