One possible approach might be, rather than rotating the next segment around the middle of the edge, make each segment rotate around whichever corner is on the outer side of the bend.
This way you don't have to fix gaps after the fact by moving things, since there will never be gaps in the first place.
If the tunnel is moving rightward, then when the tunnel bends down, you rotate the next segment around the top corner.
When the tunnel bends up, you rotate around the bottom corner.
This means the tunnel segments will always be fully overlapping where they join.
Here is an example capx.
In this example, the path segments have been made semi-transparent, so you can see how they overlap.