code: private void swap(Node n, Node root) {
          // assert this.root == root;
  
          Node nLeftChild = n.o_c;
          if (root.o_c == n) {
              if (n.y_s == root) {
                  // n is left child and no right sibling
                  n.o_c = root;
                  root.y_s = n;
              } else {
                  // n is left child and has right sibling
                  root.y_s = n.y_s;
                  root.y_s.y_s = n;
                  n.o_c = root;
              }
          } else {
              // n is right child
              root.o_c.y_s = root;
              n.o_c = root.o_c;
              root.y_s = n;
          }
          n.y_s = null;
  
          // hang children
          root.o_c = nLeftChild;
          if (nLeftChild != null) {
              if (nLeftChild.y_s == n) {
                  nLeftChild.y_s = root;
              } else {
                  nLeftChild.y_s.y_s = root;
              }
          }
          this.root = n;
      }
docs: /*
  Swap a node with its parent which must be the root.