Cute. Exploits the fact that the maze is divided in two parts (two connected components -- a left and right wall) by the path through it. I didn't understand the technique at first and had to stare at it for a few minutes. If your maze is not constructed this way (i.e., the entry or exit point is in the middle of the maze, or there are any "bridges"), then it will probably not work.