public Template Convert(TemplateItem templateItem, TemplateCollection owner) { var builder = templateItem.BuildTemplate(owner); foreach (SectionItem section in templateItem.Children.OfType <SectionItem>()) { var sectionBuilder = section.Build(builder); foreach (FieldItem field in section.Children.OfType <FieldItem>()) { field.Build(sectionBuilder); } } return(builder.Template); }