from functools import reduce


def getitem_by_path(d, path):
    """Access item in d using path.

        a = { 0: { 1: 'item' } }
        getitem_by_path(a, [0, 1]) == 'item'
    """
    return reduce(
        lambda d, k: d[k],
        path,
        d
    )