from typing import Dict
from typing import Any
from typing import Iterable
from typing import Hashable


def get_in(
    dictionary: Dict[Any, Any],
    keys: Iterable[Hashable],
    default: Any = None,
) -> Any:
    """Traverses a set of nested dictionaries using the keys in
    kws, and returns the value assigned to the final keyword
    in the innermost dictionary. Calling get_in(d, [X, Y])
    is equivalent to calling d.get(X).get(Y), with the
    difference that any missing keys causes the default value
    to be returned.

    Behavior on non-dictgionaries is undefined."""
    keys = list(keys)
    for key in keys[:-1]:
        try:
            dictionary = dictionary[key]
        except KeyError:
            return default

    return dictionary.get(keys[-1], default)