def METHOD_NAME(idp: IdentityProvider, user: User) -> Optional[Identity]:
    identities = Identity.objects.filter(
        idp=idp,
        user=user,
        status=IdentityStatus.VALID,
    )
    if not identities:
        return None
    return identities[0]