How to repair programmatically this crazy face?

Might have to do with the single vertex bug ?

Notice that the area’s in the entity info of the inner loops are substracted from the larger ones.