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.

def set_parent(self, node):
        """
        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.

        """
        self._parent = node

        if node is None:
            # detach from parent
            self._depth = 0
        else:
            self._depth = node.get_depth() + 1