A heuristic underlies the search for relief in fruit flies