void InsertAndUpdateChildrenFrom(IList <AXmlObject> srcList)
        {
            for (int i = 0; i < srcList.Count; i++)
            {
                // End of our list?
                if (i == this.Children.Count)
                {
                    InsertChild(i, srcList[i]);
                    continue;
                }
                AXmlObject child    = this.Children[i];
                AXmlObject srcChild = srcList[i];

                if (child.CanUpdateDataFrom(srcChild))                   // includes offset test
                // Does it need updating?
                {
                    if (child.LastUpdatedFrom != srcChild)
                    {
                        child.UpdateDataFrom(srcChild);
                        AXmlContainer childAsContainer = child as AXmlContainer;
                        if (childAsContainer != null)
                        {
                            childAsContainer.InsertAndUpdateChildrenFrom(((AXmlContainer)srcChild).Children);
                        }
                    }
                }
                else
                {
                    InsertChild(i, srcChild);
                }
            }
            Assert(this.Children.Count == srcList.Count, "List lengths differ after update");
        }
        void RemoveChildrenNotIn(IList <AXmlObject> srcList)
        {
            Dictionary <int, AXmlObject> srcChildren = srcList.ToDictionary(i => i.StartOffset);

            for (int i = 0; i < this.Children.Count;)
            {
                AXmlObject child = this.Children[i];
                AXmlObject srcChild;

                if (srcChildren.TryGetValue(child.StartOffset, out srcChild) && child.CanUpdateDataFrom(srcChild))
                {
                    // Keep only one item with given offset (we might have several due to deletion)
                    srcChildren.Remove(child.StartOffset);
                    // If contaner that needs updating
                    AXmlContainer childAsContainer = child as AXmlContainer;
                    if (childAsContainer != null && child.LastUpdatedFrom != srcChild)
                    {
                        childAsContainer.RemoveChildrenNotIn(((AXmlContainer)srcChild).Children);
                    }
                    i++;
                }
                else
                {
                    RemoveChild(i);
                }
            }
        }