Python A* implementation