Probably an easy solution to this problem, but was having a difficult time trying to figure out how one could generate a branching based off of the results from find similar. So that values with the same x coordinate would be in their own respected tree's.
if you start earlier with polylines from the grid points you can avoid lots of lists and tree management, that get messed up with remove duplicates etc.
Thank you for the revised version worked out a lot better. Also wanted to know if the similar sets could also be grafted into tree's in case I decide to use it in the future.