trees.py
def _remove_root(self) -> None:
        """
        Remove the root of this tree. If this tree is not a leaf, the root will
        be replaced by a closet point found in its descendants, so the
        _lt and _gt relationship of the descendants will be maintained.
        """
        if self.is_leaf():
            self._point, self._name = None, None
        elif self._split_type == 'x':
            if self._lt:
                if self._lt.is_leaf():
                    self._point, self._name = self._lt._point, self._lt._name
                    self._lt = None
                else:
                    root_node = self._lt._find_root(self._lt, 'x', 'l')
                    self._point, self._name = root_node._point, root_node._name
                    if root_node.is_leaf():
                        self._lt._remove_node(root_node)
                    else:
                        root_node._remove_root()
            else:
                if self._gt.is_leaf():
                    self._point, self._name = self._gt._point, self._gt._name
                    self._gt = None
                else:
                    root_node = self._gt._find_root(self._gt, 'x', 'g')
                    self._point, self._name = root_node._point, root_node._name
                    if root_node.is_leaf():
                        self._gt._remove_node(root_node)
                    else:
                        root_node._remove_root()
        else:
            if self._lt:
                if self._lt.is_leaf():
                    self._point, self._name = self._lt._point, self._lt._name
                    self._lt = None
                else:
                    root_node = self._lt._find_root(self._lt, 'y', 'l')
                    self._point, self._name = root_node._point, root_node._name
                    if root_node.is_leaf():
                        self._lt._remove_node(root_node)
                    else:
                        root_node._remove_root()
            else:
                if self._gt.is_leaf():
                    self._point, self._name = self._gt._point, self._gt._name
                    self._gt = None
                else:
                    root_node = self._gt._find_root(self._gt, 'y', 'g')
                    self._point, self._name = root_node._point, root_node._name
                    if root_node.is_leaf():
                        self._gt._remove_node(root_node)
                    else:
                        root_node._remove_root()

        Remove the root of this tree. If this tree is not a leaf, the root will
        be replaced by a closet point found in its descendants, so the
        _lt and _gt relationship of the descendants will be maintained.
        
Remove the root of this tree. If this tree is not a leaf, the root will
be replaced by a closet point found in its descendants, so the
_lt and _gt relationship of the descendants will be maintained.
Remove the root of this tree . If this tree is not a leaf the root will be replaced by a closet point found in its descendants so the _lt and _gt relationship of the descendants will be maintained .
def _remove_root(self) -> None:
        if self.is_leaf():
            self._point, self._name = None, None
        elif self._split_type == 'x':
            if self._lt:
                if self._lt.is_leaf():
                    self._point, self._name = self._lt._point, self._lt._name
                    self._lt = None
                else:
                    root_node = self._lt._find_root(self._lt, 'x', 'l')
                    self._point, self._name = root_node._point, root_node._name
                    if root_node.is_leaf():
                        self._lt._remove_node(root_node)
                    else:
                        root_node._remove_root()
            else:
                if self._gt.is_leaf():
                    self._point, self._name = self._gt._point, self._gt._name
                    self._gt = None
                else:
                    root_node = self._gt._find_root(self._gt, 'x', 'g')
                    self._point, self._name = root_node._point, root_node._name
                    if root_node.is_leaf():
                        self._gt._remove_node(root_node)
                    else:
                        root_node._remove_root()
        else:
            if self._lt:
                if self._lt.is_leaf():
                    self._point, self._name = self._lt._point, self._lt._name
                    self._lt = None
                else:
                    root_node = self._lt._find_root(self._lt, 'y', 'l')
                    self._point, self._name = root_node._point, root_node._name
                    if root_node.is_leaf():
                        self._lt._remove_node(root_node)
                    else:
                        root_node._remove_root()
            else:
                if self._gt.is_leaf():
                    self._point, self._name = self._gt._point, self._gt._name
                    self._gt = None
                else:
                    root_node = self._gt._find_root(self._gt, 'y', 'g')
                    self._point, self._name = root_node._point, root_node._name
                    if root_node.is_leaf():
                        self._gt._remove_node(root_node)
                    else:
                        root_node._remove_root()
def _remove_root ( self ) -> None : if self . is_leaf ( ) : self . _point , self . _name = None , None elif self . _split_type == 'x' : if self . _lt : if self . _lt . is_leaf ( ) : self . _point , self . _name = self . _lt . _point , self . _lt . _name self . _lt = None else : root_node = self . _lt . _find_root ( self . _lt , 'x' , 'l' ) self . _point , self . _name = root_node . _point , root_node . _name if root_node . is_leaf ( ) : self . _lt . _remove_node ( root_node ) else : root_node . _remove_root ( ) else : if self . _gt . is_leaf ( ) : self . _point , self . _name = self . _gt . _point , self . _gt . _name self . _gt = None else : root_node = self . _gt . _find_root ( self . _gt , 'x' , 'g' ) self . _point , self . _name = root_node . _point , root_node . _name if root_node . is_leaf ( ) : self . _gt . _remove_node ( root_node ) else : root_node . _remove_root ( ) else : if self . _lt : if self . _lt . is_leaf ( ) : self . _point , self . _name = self . _lt . _point , self . _lt . _name self . _lt = None else : root_node = self . _lt . _find_root ( self . _lt , 'y' , 'l' ) self . _point , self . _name = root_node . _point , root_node . _name if root_node . is_leaf ( ) : self . _lt . _remove_node ( root_node ) else : root_node . _remove_root ( ) else : if self . _gt . is_leaf ( ) : self . _point , self . _name = self . _gt . _point , self . _gt . _name self . _gt = None else : root_node = self . _gt . _find_root ( self . _gt , 'y' , 'g' ) self . _point , self . _name = root_node . _point , root_node . _name if root_node . is_leaf ( ) : self . _gt . _remove_node ( root_node ) else : root_node . _remove_root ( )
Remove the root of this tree.
Remove the root of this tree .
"""
        Remove the root of this tree. If this tree is not a leaf, the root will
        be replaced by a closet point found in its descendants, so the
        _lt and _gt relationship of the descendants will be maintained.
        """
self