performance: stop pathfinding once best path is found