Maybe use the MShadow calculations to cull all the internal edges and join only the external ones in closed polylines?