from typing import Dict
from typing import Any
from functools import reduce


def extract(dictionary: Dict, keys: str, default: Any = None) -> Any:
    """Wrap around dictionary item, return None or empty list in case it does not exist
    # https://stackoverflow.com/questions/25833613/safe-method-to-get-value-of-nested-dictionary

    Args:
        dictionary: dictionary to parse
        keys: path to item, e.g. dict['level1']['level2'] => level1.level2
        default: what to return in case of None

    Returns:
        Any: Extracted

    """
    return reduce(
        lambda d, key: d.get(key, default)
        if isinstance(d, dict)
        else default, keys.split("."), dictionary
    )