private void GetDistinctProjects(ProjectList projects, ProjectList projectList) { // ProjectList projectList = new ProjectList(); foreach (Project project in projects) { if (!projectList.Any(x => x.Name == project.Name)) projectList.Add(project); foreach (string refer in project.ReferenceList) { Project tmp = new Project(); tmp.Name = refer; if (!projectList.Any(x => x.Name == refer)) projectList.Add(tmp); } foreach (Project reference in project.ReferencedProjects) { if (!projectList.Any(x => x.Name == reference.Name)) { projectList.Add(reference); GetDistinctProjects(reference.ReferencedProjects, projectList); } } } }