Geometry Nodes Merge by distance with outside mesh islands and not itself

I have been trying and looking everywhere but I can’t figure out how to merge the edges of islands to the other islands, I have a selection for the edges of each island but merge by distance merges the connected vertices too, I need it to merge only with the outside mesh islands.

Hi Rozwan,
I didn’t find a solution to directly merge from border to border, but I created some kind of bridge with extrude edges to the next border. Hope it will help !
You can use the blend file as you wish (4.1)

GeometryNodesMergeByDistance.blend (1.3 MB)