I just realized that if the maze features overpasses/underpasses, then it would a little bit more complicated as you'd have to expand the maze into 3 dimensions (probably by examining each overpass individually), but the basic idea would be the same.
Abusive comment hidden.
(Show it anyway.)