Dumb A* implementation.