Neighbor numbering of triangulated mesh

I have a triangulated mesh object, which I numbered according to the Z coordinate of the triangle center.
I would like to create a new list of neighboring triangles where the next highboring triangle is chosen among the three available which has the highest Z coordinate.
This requires the the base list is shrinked in every step according to the picked neighbors, which is requires recursivity. Isn’t it?

Do I need hoopsnake, or it can be done in plain grasshopper?

  1. Are you in general familiar with Connectivity and for this case Mesh Connectivity matters? (FF connectivity for your task).
  2. If I got it correctly you need to sample Faces in some kind of “path” upwards (starting from some “low” one) … and if yes, then indeed you’ll need a looping approach.

Check out Starling. You can get a tree made of lists of the adjacent faces for each face. Then the sorting part can be handled by standard Grasshopper tools.

Starling is a bit odd in that it wants polylines as an input. You can use Face Boundary to get those polylines from a mesh.