Implement A* search.