def ensure_bool(val):
    """
    Converts query arguments to boolean value.

    If None is provided, it will be returned. Otherwise, value is lowered and
    compared to 'true'. If comparison is truthful, True is returned, otherwise
    False.

    :param val: Value to convert to boolean.
    :return: boolean value
    """
    if val is None:
        return None
    return val.lower() == 'true'