from functools import reduce
import operator


def get_from_dictionary(xml_dictionary, key_list):
    """Finds the specified nested key into a dictionary.

    Raises ``KeyError`` exception if the ``key_list`` is not found in dictionary.
    Raises ``TypeError`` exception if the ``key_list`` type mismatches with dictionary.
    Raises ``IndexError`` exception if the ``key_list`` index is out of range.

    Parameters
    ----------
    xml_dictionary : dict
        nested data structure to find the value

    key_list : list
        the nested path

    Returns
    -------
    Returns the sub_dictionary matches with ``key_list``."""

    try:
        return reduce(operator.getitem, key_list, xml_dictionary)
    except (KeyError, TypeError, IndexError) as e:
        raise e