def METHOD_NAME(self, server_url, handle=None):
    stored_assocs = OpenIDStore.objects.filter(server_url=server_url)
    if handle:
        stored_assocs = stored_assocs.filter(handle=handle)
    stored_assocs.order_by("-issued")
    if not stored_assocs.exists():
        return None
    return_val = None
    for stored_assoc in stored_assocs:
        assoc = OIDAssociation(
            stored_assoc.handle,
            base64.decodebytes(stored_assoc.secret.encode("utf-8")),
            stored_assoc.issued,
            stored_assoc.lifetime,
            stored_assoc.assoc_type,
        )
        # See:
        # necaris/python3-openid@1abb155c8fc7b508241cbe9d2cae24f18e4a379b
        if hasattr(assoc, "getExpiresIn"):
            expires_in = assoc.getExpiresIn()
        else:
            expires_in = assoc.expiresIn
        if expires_in == 0:
            stored_assoc.delete()
        else:
            if return_val is None:
                return_val = assoc
    return return_val