def METHOD_NAME(self, key, root):
    if not root:
        return None
    # Header node for easier manipulation
    header = Node(None)
    header.left = header.right = None
    LeftTreeMax = RightTreeMin = header
    # Splay the key to the root of the tree
    while True:
        if key < root.key:
            if not root.left:
                break
            if key < root.left.key:
                # Zig-Zig (Right-Right) rotation
                root = self.RR_Rotate(root)
                if not root.left:
                    break
            RightTreeMin.left = root
            RightTreeMin = RightTreeMin.left
            root = root.left
            RightTreeMin.left = None
        elif key > root.key:
            if not root.right:
                break
            if key > root.right.key:
                # Zag-Zag (Left-Left) rotation
                root = self.LL_Rotate(root)
                if not root.right:
                    break
            LeftTreeMax.right = root
            LeftTreeMax = LeftTreeMax.right
            root = root.right
            LeftTreeMax.right = None
        else:
            # Key found at the root, break the loop
            break
    # Reassemble the tree
    LeftTreeMax.right = root.left
    RightTreeMin.left = root.right
    root.left = header.right
    root.right = header.left
    return root