Check if atom is placed too near to another

I’m trying to write a fix that teleports particles to a random location.
However new location can be outside of the domain owned by this proc. How do I check the new location is not too close to another atoms than given criteria?
Or should I say, how do I get nearest neighbors of an atom if I move it outside owned domain?
Can be it done by just occasionally forcing neighbor list rebuilding inside a fix function?

Please have a look at the code for the create_atoms command for creating atoms at random locations and how it handles its overlap keyword.

Thank you.
It just uses the fact the random generators initialized with the same seed will generate the same numbers for all procs.