Random delete in a curve lattice

Hello everyone,

I am starting to work on a geometry node project to up my geometry node skills.
For now I am creating a lattice out of curve with embedded curve instances on a cubic point grid. I got to the point where I can shape the lattice and then random delete inside of it.

I am wondering what to do in order to never have a curve which floats above the ground. In other terms, no curve should be completely disconnected from the others. Any hints and ideas welcome!

I have the feeling that what I am doing now is not the most elegant solution and the next steps will be to do a loop based tool based on this tutorial.

Here is the link to the file.

Thank you and have a great day!