Algorithm to find all connected objects
Thanks for your answers!
I looked into both connected components in an undirected graph and the Disjoint set and went for the latter.
After researching this dataset I found a few packages that provided an implementation, but I used this one:

https://github.com/nawatts/disjoint

I'm a junior developer and haven't really come in contact with this kind of problems so your points in the right direction are very much appreciated.