code: static <K,V> TreeNode<K,V> rotateLeft(TreeNode<K,V> root,
                                                TreeNode<K,V> p) {
              TreeNode<K,V> r, pp, rl;
              if (p != null && (r = p.right) != null) {
                  if ((rl = p.right = r.left) != null)
                      rl.parent = p;
                  if ((pp = r.parent = p.parent) == null)
                      (root = r).red = false;
                  else if (pp.left == p)
                      pp.left = r;
                  else
                      pp.right = r;
                  r.left = p;
                  p.parent = r;
              }
              return root;
          }
docs: Red-black tree methods, all adapted from CLR