How to compare elements in different lists and replace them

I have list of points in branches.Points in lists are such that the last point of the first list and first point of the adjacent list have same XY-cordinates but different Z-levels.I want these points to have same Z- levels which should be maximum out of both the points.
I am looking for a way to make this comparison and replace the points in the native lists.
I am going to use these points to construct a column. So want to have one post with maximum Z- level at that common location.Currently I have two posts modelled at same location(See attached picture).
I will flatten the list and remove the duplicate points and then model the columns.
I have attached a gh file with the reference data.

Thank you!
Ayush (15.6 KB)


Something like this works, it’s losing the tree structure though, if you need to keep it something else has to be thought of. (22.2 KB)

1 Like

It worked @magicteddy .
Thank you!
But I have another situation as well where last point of the first list and first point of the adjacent list don’t have same XY- cordinates rather they are away by a specific distance say 3m. I want the Z- level of these points to be same(Maximum of the both).
I have attached a sample gh file with the list of point data and picture for your reference. (57.4 KB)

Until someone provides a component based solution … get the attached. (30.3 KB)

1 Like

Here it is for the sake of completion, but @PeterFotiadis C# component is far more compact - it doesn’t even need the BTree input which makes it even lighter ! (36.3 KB)

1 Like

Well … if we want to replace items in 1st, 2nd or both Trees we need both Trees. See newly modified attachment.

Update: Added some verbosity (144.9 KB) (20.1 KB)

Thank you @magicteddy

Thank you @rajeev_pulari

Thank you @PeterFotiadis