I think I can fix that in a couple of ways. One is by doing binary search, which should cut down on some time.
A second point is that I don't *actually* need to know *all* the paths in each direction. I just need to know which direction has *more* paths.