public void Accept(IElementVisitor visitor) { visitor.Visit(this); if (this.HasChildNodes) { visitor.BeginContainer(this); foreach (var item in this.ChildNodes) { if (item is IElementVisitorTarget evt) { evt.Accept(visitor); } } visitor.EndContainer(this); } }