Minimal A* implementation