def get_E2K_lookup_dict(the_dict, main_key, sub_key):
    """Returns a lookup dictionary specified by main_key
    and sub_key, returning an empty dictionary if any is missing.
    This is for use in the post-processing functions."""
    subdict = the_dict[main_key].get(sub_key, {}) \
        if the_dict.get(main_key) else {}
    if subdict:
        return {v.get('ID'): k for k, v in subdict.items() if v.get('ID')}