private static void RemoveSameParent(Node startNode, Node endNode)
{
if ((endNode != null) && ((Node)startNode.ParentNode != (Node)endNode.ParentNode))
throw new ArgumentException("Start and end nodes are expected to have the same parent.");
Node curChild = startNode;
while ((curChild != null) && (curChild != endNode))
{
Node nextChild = curChild.NextSibling;
curChild.Remove();
curChild = nextChild;
}
}