Attemt to make findPaths tail recursive.