public TreeNode GetNextSiblingWithXmlElement(string localName) { if (Parent == null) { return(null); } TreeNode next = this; while ((next = next.NextSibling) != null) { if (next.HasXmlProperty && next.GetXmlElementLocalName() == localName) { return(next); } TreeNode nextIn = next.GetFirstDescendantWithXmlElement(localName); if (nextIn != null) { return(nextIn); } } return(Parent.GetNextSiblingWithXmlElement(localName)); }