def first_leaf(nested_dict):
    """
    On the assumption that all the leaves of a nested dictionary (tree) structure are in some way equivalent,
    this is a quick method of returning the first such leaf without knowing the specific keys used
    to construct the nested dict.
    """
    partial_dict = nested_dict
    while True:
        try:
            partial_dict = partial_dict[list(partial_dict.keys())[0]]
        except AttributeError:
            try:
                partial_dict = list(partial_dict)
            except TypeError:
                return partial_dict
            else:
                partial_dict = partial_dict[0]
