def swap(self, node_u, node_v):
        # Make the second node the root if this node has no parent.
        if not node_u.parent:
            self.root = node_v
        # Swap the nodes, depending on if the node is a left or right child.
        elif node_u == node_u.parent.left_child:
            node_u.parent.left_child = node_v
        else:
            node_u.parent.right_child = node_v
        # Swap the nodes' parents, thus "unhooking" the branch
        if node_v:
            node_v.parent = node_u.parent
Swap two nodes.
dataset/ETHPy150Open christabor/MoAL/MOAL/data_structures/trees/splay_trees.py/SplayTree.swap