moveAfter function

bool moveAfter(
  1. FNode root,
  2. FNode target,
  3. FNode sibling
)

Moves target after sibling in the tree. Equivalent to removeNode + insertAfter on the parent of sibling.

Implementation

bool moveAfter(FNode root, FNode target, FNode sibling) {
  final siblingParent = findParent(root, sibling);
  if (siblingParent == null) return false;
  if (!removeNode(root, target)) return false;
  return insertAfter(siblingParent, sibling, target);
}