# How can I handle two trees interacting eath other?

Hello everyone:
I met a problem about two trees interacting.
As you see, tree ‘layers’ has three branches, they are numbers; tree ‘domains’ has 15 branches, they are domains. Now I need use the domains to evaluate each branch of ‘layers’, thus I should I have a new tree of 45 branches.
However, I got the new tree of 15 branches.
Could anyone help me fix the problem?
Thanks a lot!!

domains.gh (25.4 KB)

if you have a short list and a long list, the last item/branch of the short list will be duplicated until the lengths of the two lists are equal

that’s why you get the last 13 branches with exactly 490 items each (490 is the length of the last branch that gets duplicated until 15 branches are present)

it is not completely clear to me what item from which list you would to compare to which item from which other list

for instance, if you want to compare each item of layers to all the values in domains you could graft the Layers and flatten the Domains:

it will produce a tree like {a, b} (c) where:
a = original layer branch of each Layer (in this case 3 branches {0, 1, 2} )
b= index of item in branch (for a=0 → 457 branches, a=1 ->462 branches, a=2 ->490 branches)
c= 15 values, one for each Domain that gets checked

2 Likes

Sorry I forgot to attache the gh file.
What I want is to use domain check each layer. So finally I should I have 45 branches.

the Layer parameter contains 3 branches: if each branch had just one item, then it would be 45 items in total:

this might sound silly to you, but when I’m in these kind of situations it really helps me out to “enunciate” in words what I would like to get as final result

the example in my previous post could be worded like: compare each item in each branch of Layers with all the items in Domain

1 Like

Thank you so much for your efforts to help me, @inno!
However, it’s still not what I want. Because I need 45 branches.
@aquintana 's solution is very clost to my aim.
Thanks again!

Thanks a lot, @aquintana!!
Yes, you got the results I want.
Do you think can we move further: if the branch numbers of ‘layers’ are not fixed (here is 3, it can be 200), I have to create losts of ‘incluse’ to hold the big number of braches.
Thank you again!