private void TreetoList(AuthorityTreeModel root) { var num = root.ButtonAuthorityList.Where(m => m.IsChecked).Sum(g => g.ButtonID); if (num > 0) { UserAuthority.Add(new UserCustomerAuthority { StructureID = root.StructureID, UserButtonAuthority = num }); } if (root.children != null && root.children.Count > 0) { foreach (var child in root.children) { TreetoList(child); } } }