Fix cascaded deletion of polymorphic models

Currently, when deleting polymorphic models (for example by using `django-polymorphic`), the `django.db.models.deletion.Collector` incorrectly assumes that all models are of the same type as the first model in the list. Then, it generates incorrect delete statements when polymorphic models are used which then result in an `IntegrityError` when the transaction is committed. This is a patch that fixes this issue and it is directly based on a patch submitted by Kronuz at the end of ticket #16128.