from typing import Union
from typing import Sequence
from typing import Mapping
from typing import Any


def chain_idx(container: Union[Sequence, Mapping], key_list: Sequence) -> Any:
    """Get an element at a path in an arbitrarily nested container.

    Args:
        container (Union[Sequence, Mapping]): container from which to try to retrieve element.
        key_list (Sequence): list of index and/or keys specifying the path.

    Returns:
        Element found at the specified path.

    """
    curr = container
    for key in key_list:
        curr = curr[key]
    return curr