How can I compute (0)with（0，0）（0，1），（1）with（1，0）（1，1）（1，2），（2）with（2，0），（2，1）in next tool?

I’m sorry but I don’t understand the question. Can you elaborate?

You need to match the first tree with the second, it’s usually done by duplicating data and reorganizing it. If you repeat the element of the branch {0} 2 times (for {0:0} and {0;1}), the branch {1} 3 times and that of the branch {2} 2 times, you get:
{0} N = 2
{1} N = 3
{2} N = 2
and you make them graft, you get:
{0;0} N = 1
{0;1} N = 1
{1;0} N = 1
{1;1} N = 1
{1;2} N = 1
{2;0} N = 1
{2;1} N = 1

you will have an element in the first tree for each branch of the second tree.

Thank you. But, in my program, I don’t know how many times should I duplicate branches in the first tree. It’s dynamic. In other word, the amount of branches the second tree is dynamic.
Can you help?

If I understand you aright, just connect them and Grasshopper will handle the matching:

Apologies if I have misunderstood - posting your .gh file with internalised data should make it easier to understand your need.

Regards
Jeremy

Of course in my solution you don’t have to put explicitly 2,3,2, because in no case they are hyperparameters, but they are data of internal processes. You have to obtain these numbers in a programmatic way, measuring the size of the branches on the fly.

Obtain tree branch paths using TreeStatistics, decompose paths indices using DeconstructPath (or whatever it’s called), get the first path index using ListItem, measure how many times each index is repeated.