public TreeNode GetNextSiblingWithXmlAttribute(string attrName) { if (Parent == null) { return(null); } TreeNode next = this; while ((next = next.NextSibling) != null) { if (next.HasXmlProperty && next.GetXmlProperty().GetAttribute(attrName) != null) { return(next); } TreeNode nextIn = next.GetFirstDescendantWithXmlAttribute(attrName); if (nextIn != null) { return(nextIn); } } return(Parent.GetNextSiblingWithXmlAttribute(attrName)); }