Depth First Search and Recursion in Dynamo

I’m following a general discussion about Inductive Graphs and how to build some basic functions in Haskell, in an attempt to create a Dynamo script that can generate an Electrical One-Line Diagram.

The first thing is to create the Depth First Search that will traverse all the nodes in the graph/network. This is what i have so far. The first time i ran it, Revit used 20GB of ram, so some sort of memory leak. I expect it has something to do with not having an ‘abort’ or ‘stop’ condition in the function for the recursion.

I should probably think about this some more before I go asking so many questions.

This is pretty cool (using a Haskell-style / functional solution in Dynamo). Where did you get with this in the end?