Trim data tree based on curve or line

Hi all, I am trying to split a data tree of surfaces based on a line or a curve or multiple. Attached is the simplified script. In the first example, see first screenshot, I am trying to remove the surfaces to the right of the line. In the second example I am trying to split the the surfaces based on the curve and remove the ones below the curve. However I need to keep the surfaces intact so they cannot be trimmed where the curve intersects them but at the nearest joint. For the first example I found the nearest points to the split line on the surface grid. For the second example the nearest points are only working partially for some reason. In each example I still can’t find a way to split the data tree. I tried joining the surfaces in each row and then using the BREP SPLIT component but it doesn’t work. I tried several ways to sort the data tree but I don’t know how to make a cull pattern based on the line/curve. Any tips would be much appreciated. I will have several lines and curves and trying to understand how to best go about this. Thanks!

SPLIT DATA TREE FOLLOWING A LINE OR A CURVE.gh (83.0 KB)