Checking Overlapping UV in C++

Hi everyone
I’m working on a editor tool, and I’m trying to find a way to check for overlapping vertices in a lightmap UV.
I found an existing function in UStaticMesh::CheckLightmapUVs, but as the comment describes it is not used anymore because it’s way too slow on meshes with high number of polys.
So i’m trying to find an alternative that’s a bit faster* (right now it takes more than 5 minute on very high res mesh, i need something instantaneous).*

I looked into the code that triggers the “Lightmap UV are Overlapping by x %” when building lighting.
But that’s all in the Lightmass source code, and that does not seem to be accessible from my plugin code (it’s on github but it’s not in my editor source code from the launcher version), and since i’m writing a marketplace plugin i need it to work anywhere.

Would anyone have any idea or lead as to how i could approach this in a more efficient way?

The CheckLightmapUV function basically takes every single triangle, calculates the center, and then checks every other single triangle in the mesh to see if it overlaps. (which yeah, of course will be slow)
The other function in Lightmass seems to be using the texels from the light build to more easily check if there’s an overlap. That seems promising but yeah it’s not accessible.
I also need this function to work without having to build the lights.

Any help or idea would be very appreciated