The actual algorithm is somewhat different, and documented here: https://intarch.ac.uk/journal/issue59/3/full-text.html
What you have described feels like a variant of Eller’s algorithm: https://weblog.jamisbuck.org/2010/12/29/maze-generation-elle...