Ideally drop the `isinstance`, something like `if pk_field.rel and getattr(pk_field.rel, 'parent_link', None)` might do the trick.