Refactor my fix for PR5652 to terminate the predecessor lookups after the first failure.