Projecting curves onto overlapping surfaces

I’m looking for a nice way to project a curve onto multiple surfaces such that the curve gets trimmed if it has already “hit” a surface above it. This is part of a python script – anyone have a nice way of doing this with rhinoscriptsyntax or RhinoCommon?

The rs.ProjectCurveToSurface seems to do a projection for each surface. I have considered writing some code that would duplicate the border of the top surface, extrude it, and trim the projected curve below, but I suspect there is a good way using available functions?

A partial alternative seems to be:

  1. Project the first curve onto the other surfaces
  2. Project each newly created curve onto the other surfaces
  3. _Split the curves from step 1 with the curves from step 2
  4. Find a way to select the ‘almost’ matching curves. _SelDup doesn’t work for me here - a tolerance issue?

This script from @Helvetosaur might help with step 4 - I wonder whether he has a Python equivalent …?