I think that lower down in this method there would still remain a chance that if the for loop exists after this iteration that you would still be returning null for the relationship object.

Do you want to add a check below that if it's null just return nil at the end?