private static Node AddBeforeCurrent(Node parent, Node previous, Node current, Node toAdd) { if (previous == null) { if (!(current == parent.GetFirstChild())) { Kit.CodeBug(); } parent.AddChildToFront(toAdd); } else { if (!(current == previous.GetNext())) { Kit.CodeBug(); } parent.AddChildAfter(toAdd, previous); } return toAdd; }