protected int addChildren(DiffSeg seg, List <DiffSeg> segs, int index)
        {
            if (!seg.tag || seg.selfClosing || !seg.startTag)
            {
                return(index);
            }

            List <DiffSeg> children = seg.getChildren();

            children.Clear();
            for (index++; index < segs.Count; index++)
            {
                var cseg = segs[index];

                var ender = !cseg.startTag && cseg.tag;
                children.Add(cseg);
                if (ender)
                {
                    //The differ tends to make previous ending tags be "changed" if the same tag is on the end of what was really changed, and the real closing tag is "the same"
                    //If the HTML is valid, then we can be certain that if we're at an ending tag at this point in our recursion, then it must be the case where it was marked incorrectly
                    seg.op = cseg.op;

                    return(index);
                }

                index = addChildren(cseg, segs, index);
            }
            //This *should* mean bad html.  So we'll hack an end tag in.
            children.Add(new DiffSeg(seg.op, "</" + seg.tagName + ">"));
            return(index);
        }
 public void addChild(DiffSeg seg)
 {
     if (!CanHaveChildren)
     {
         throw new Exception("Non-tag diff segments have no children");
     }
     this.children.Add(seg);
 }