def get_loc_from_dict(dct, loc):
    """
    Take a string loc and return a sub-dict corresponding to that loc.

    i.e. "foo.bar" would return dict['foo']['bar']

    empty string returns top-level dict.
    """
    if loc == "":
        return dict
    else:
        locs = loc.split(".")
        d = dct
        for ll in locs:
            try:
                d = d[ll]
            except KeyError:
                raise KeyError(f"loc {loc} does not exist in dict {dct}")

        return d