public static void AddUniqueDiagnostics(myTreeNode mtnDiagnosticList, List <Diagnostic> diagList) { // remove existing diags from the above list if they already exist in the treeview foreach (myTreeNode mtn in mtnDiagnosticList.Nodes) { // remove matching diagnostic in diagList diagList.RemoveAll(d => d.GetType() == mtn.diagnostic.GetType()); } // add remaining diags to the diag list in the treenode foreach (Diagnostic d in diagList) { myTreeNode mtnd = mtnDiagnosticList.AddMyTreeNodeObject(myTreeNode.TREENODE_OBJ_TYPE.DiagnosticDetails, d.ToString()); mtnd.diagnostic = d; d.displayTreeNode = mtnd; } }