def parse_boolean(value):
    """
    if value is None returns None.

    if value is boolean, it is returned as it is.
    if value is str and value is equals ignoring case to "True", True is returned.
    if value is str and value is equals ignoring case to "False", False is returned.

    For every other value, the answer is undefined.

    :param value:
    :return:
    """
    if value is None:
        return None
    if value in (True, False):
        return value
    try:
        return {'true': True, 'false': False}[value.casefold()]
    except (AttributeError, KeyError):
        raise ValueError(f'unknown string for bool: {value!r}')
