finally fully compliant A* algorithm