def get_from_tree(tree, key_path):
    """Return the value in a nested dict from walking down along the specified keys.

    Args:
        tree: a nested dict.
        key_path: an iterable of the keys to follow. If keys is a string, uses
        keys as a single key.
    """
    cursor = tree
    if isinstance(key_path, str):
        return cursor[key_path]
    for key in key_path:
        cursor = cursor[key]
    return cursor