call the method references_to_delete.setdefault with arguments: r.rel.to and an empty list, append to the result tuple with 2 entries: model and f.
references_to_delete . setdefault ( f . rel . to , [ ] ) . append ( ( model , f ) )