Fix merging of polygons where the closing edge would connect back
As we take out the closing edge one level above this to overall simplify things, we need to handle this special case here now.