Implements backtrace maze algorithm