from typing import Mapping
from typing import Optional
from typing import Any
from functools import reduce


def get_value_by_dot_notation(dict_obj: Mapping, key: str, default: Optional[Any] = ...) -> Any:
    """
    Return the value of a key in dot notation in a arbitrarily nested Mapping.
    dict_obj: Mapping
    key: str
    default: Any
    raises: KeyError if default is not provided and the key is not found
    ex.:
        dict_obj = {"nested": {"key": "value"}}
        get_value_by_dot_notation(dict_obj, "nested.key") == "value" -> True
    """

    return reduce(lambda d, key_name: d[key_name] if default is ... else d.get(key_name, default), key.split("."), dict_obj)