Set the parent reftrack object

        If a parent gets deleted, the children will be deleted too.

        .. Note:: Once the parent is set, it cannot be set again!

        :param parent: the parent reftrack object
        :type parent: :class:`Reftrack` | None
        :returns: None
        :rtype: None
        :raises: AssertionError

def set_parent(self, parent):
        """Set the parent reftrack object

        If a parent gets deleted, the children will be deleted too.

        .. Note:: Once the parent is set, it cannot be set again!

        :param parent: the parent reftrack object
        :type parent: :class:`Reftrack` | None
        :returns: None
        :rtype: None
        :raises: AssertionError
        """
        assert self._parent is None or self._parent is parent,\
            "Cannot change the parent. Can only set from None."
        if parent and self._parent is parent:
            return
        self._parent = parent
        if parent:
            refobjinter = self.get_refobjinter()
            refobj = self.get_refobj()
            # set the parent of the refobj only if it is not already set
            # and only if there is one! oO
            if refobj and not refobjinter.get_parent(refobj):
                refobjinter.set_parent(refobj, parent.get_refobj())
            # add to parent
            self._parent.add_child(self)
        if not self.get_refobj():
            self.set_id(self.fetch_new_id())

        pitem = self._parent._treeitem if self._parent else self.get_root().get_rootitem()
        self._treeitem.set_parent(pitem)
        self.fetch_alien()