Prevent Pipes from Overlapping Across Multiple Regions

I couldn’t prevent the overlap in the area I marked in green. The pipes I create within each region are also being included in the operations of the other regions. How can I solve this problem?

pipe problem.gh (17.7 KB)

Don’t flatten at the end, make use of the data tree you have. Use the Trim Tree Component to match the path depths

You provided a spot-on solution. Thank you very much — I’m truly grateful. I’m new to Grasshopper and trying to improve myself.