public static void SwitchParent(IQueryNode child, IQueryNode newParent) { var parent = child.Parent; if (parent != null) { parent.RemoveChild(child); } child.ChangeParent(newParent); }