function swapParentChild(oldChild, newChild, parent) {
  if (parent) {
    // this set parent child
    const side = oldChild.isParentRightChild ? 'Right' : 'Left';
    parent[`set${side}AndUpdateParent`](newChild);
  } else {
    // no parent? so set it to null
    newChild.parent = null;
  }
}
Swap parent's child

@example Child on the left side (it also work for the right side)

p = parent
o = old child
n = new child

p           p
 \    =>     \
  o           n

@param {TreeNode} oldChild current child's parent
@param {TreeNode} newChild new child's parent
@param {TreeNode} parent parent