def METHOD_NAME(session):
    if not session:
        return None
    UserModel = get_user_model()
    try:
        user_id = UserModel._meta.pk.to_python(session[SESSION_KEY])
    except KeyError:
        return None
    else:
        try:
            return UserModel._default_manager.get(pk=user_id)
        except UserModel.DoesNotExist:
            return None