Infinite loop when drawing outlines of an object

Hello guys,

Last week I posted a question where I asked how to remove unexpected lines when using EdgesGeometry. (Removing a line from LineSegments)

The solution was using OutlinesGeometry (,
found in this issue:;

This code works great, I get the expected result.

The problem I’m having now is that this creates an infinite loop for some meshes. This code keeps splitting faces without stopping.
A mesh that triggers this looks like this (it can be rendered using EdgesGeometry):

I logged the amount of faces in the loop, and after 2 sec there are 32467 faces when it started with 73.

I’m not that great with code like this, and I can’t seem to find where the problem lies.

Does anyone have an idea?

P.S. I tried creating a jsfiddle but it takes a lot of code to come to this kind of mesh.