Compare tree branches and remove duplicated combinations

Hi everyone,

Im creating random combinations using 3 different formats - 300,400 and 500 and I need to remove duplicated combinations. I wonder if there is a good way to compare each tree branch from each data tree and remove duplicated combinations. Thank you in advance!

data_Tree_Remove duplicated (7.1 KB)

python code:

a = ["abc", "def", "ijk", "lmn", "opq", "rst", "xyz"]
b = ["ijk", "lmn", "opq", "rst", "123", "456" ]
for i in b[:]:
    if i in a:
>>> b
['123', '456']

now using this link you should be able to find a fast solution: Rhino - Grasshopper data trees and Python

another way is to comparing strings , combine your data in a row for example first item of list could be converted to this string:“300400500300400” and so on.
now you can get free from branches and then compare to next list.
hope this help.

Hi @saeed_hasan_zadeh,

Thank you for your feedback. I have been trying to get it to work and I end up with this.

I’m still very beginner in Python, so I’m a bit unsure if it is working properly. Looking at the code it seems to be but I’m not sure if the result is correct.
My first thoughts are at the correct output should be a list of branches common in both lists, but I’m getting none.

data_Tree_Remove duplicated (9.9 KB)

Get 6 takes on that matter (C# not P since I hate that thing). (119.6 KB)

Foreach option a classic Recursive LINQ Method is used (with or without repetitions blah, blah). For instance: