Enhanced A* with breakTest, which stops it mid-search if some condition is true