Problem pipe Sizing according to Dutch NTR 3216

Hi everyone,

fairly new to Revit and completely new to Dynamo, so the past couple of days I’ve been trying to learn about this amazing tool by fiddling around with it. However, now I’m stumped and can’t seem to find how to move on. I’m trying to implement drain pipe sizing based on the Dutch standard NTR 3216. This standard sizes pipes based on basic flow per plumbing fixture (‘FU’), and a formula to account for the fact that not all plumbing fixtures connected to a pipe are used at the same time ( factor * sqrt (sum(FU)) ). The factor is based on the type of building.
You calculate the formula for each pipe, also determine the highest single plumbing fixture FU, and use the max of these two values to determine what flow to use to size the pipe.

The formula part is fairy straightforward. I just use Revit’s FU to propagate the sum of the FU’s through each pipe in the system.

To determine the max single plumbing fixture FU I first tried to use MEPover’s ‘Pipe upstream components’ and then filter for plumbing fixtures, but for some reason this gave me downstream components instead.
I then tried my current attempt. I select the very last pipe (most downstream) in the system, and have set up the following to iterate through the system:

The ‘PrevFitting’ is initially empty, so I add the selected pipe to have something in the list (a non-null list) I can use operations on. I use MEPover’s Mep curve connected fittings to determine everything attached to the pipe. I then filter out the previous fitting since that’s downstream and already sorted. Then I check if there are actual Pipe Fittings on the other end of the pipe. If not, I assume the pipe is the last one in a branch and connected to either a Plumbing Fixture or Mechanical Equipment. This means that the pipe’s FU is the basic flow for that fixture or equipment, which is then output.
If there is a Pipe Fitting on the other end, I use MEPover’s MEP Fitting Connected MEPcurves to determine the pipes that are connected to this Pipe Fitting, filter out the Pipe I’m already looking at, and send the other Pipes through the same function recursively. The maximum of these results will be the maximum basic flow for the pipe I’m looking at, which is then output.
Parallel to this the maximum basic flow is compared with the formula mentioned above, to determine the flow to use for sizing the pipe (I haven’t scripted the actual sizing yet).

I tested the script before I made it recursive, and it worked as expected. The basic flow is determined correctly for ‘end of branch pipes’, and the ‘Previous Fitting’ and list of the next pipes to check out seems to work fine, too.
After making it recursive I am not getting any result at all, though. I also can’t seem to step into the function to see where it goes wrong, or am I missing some sort of debugging setting?

I’m hoping some of you who have been at this Dynamo thing for longer than my 3 day experience can point out the (hopefully obvious) thing I am missing. Any pointers will be appreciated, thanks!