How does the algorithm work?

Doesn't sound that efficient

And it most likely isn't. The goal is to have an unbiased algorithm, but this comes at the price of a slow runtime.

More refined algorithms try to fix the inevitable repetition with a constrained walk.