Data Tree merging

Hi,
I have two different data trees and I would like to merge them continuing numbering in case inside there is the same branch.
For instance:

DATA 1:
{9;23;0}
0 crv
1 crv
n crv
{9;23;1}
0 crv
1 crv
n crv

DATA 2:
{9;23;0}
0 crv
1 crv
n crv

Wished DATA after merging
{9;23;2}
0 crv
1 crv
n crv

Thanks a lot

(Data tree.gh (129.3 KB)

old {9;23;0} of DATA 1)

I did this solution, but it is not so elegant, specially why I don’t have a real continuation of numbering

upgrade:
the result looks correct… still not elegant, but I think it’s working
:smiley: