Avoid overwriting the instance found above. It was possible that None was found above because pk conversion failed (an example is model_formsets.test_custom_pk()). In that case, Django picked ith instance from the queryset. This usually happened to be the right one, but there was no guarantee it actually was.

Trying to get queryset's ith value when that value was deleted already resulted in IndexError, so this change is also needed to fix the ticket's original issue.