To get the shortest distance from Room perimeter

I want to extract the shortest side (distance) of the rooms by using Dynamo …but the curves I got from dynamo are divided by connected adjacent wall which I don’t want.
For example the rectangular room should has only 4 curves…but Dynamo report 5 curves instead.
Any suggestion on this ?

Use CurveLoop.Simplify from SpringNodes


absolutely genius…many thanks Andreas…