def crossreference_keys(table, key, informat):
    """
    Input syntax:
    table: list of cross-referenced AIF<->JSON equivalencies
    key: key to cross reference
    informat: format of input key, either AIF or JSON

    Output syntax:
    outformat: format of the output key (opposite the informat)
    Returns the outformat value of the informat key

    If the informat key is not in the equivalency table, the
    script uses a fallback handler:
       JSON key "inkey" -> AIF key "_inkey"
       AIF key "_inkey" -> JSON key "inkey"
    """

    if informat == 'AIF':
        outformat = 'JSON'
    elif informat == 'JSON':
        outformat = 'AIF'
    else:
        raise AssertionError('Unknown informat: ' + informat)

    # Cross reference the input format against the list
    #  IS THERE A BETTER WAY TO DO THIS???
    tmp_list = [x[informat] for x in table]
    if key in tmp_list:
        index = tmp_list.index(key)
        #print(table[index])
        return table[index][outformat], table[index]['dtype']

    # Handler for unknown keys:
    if informat == 'AIF':
        #strip leading "_"
        return key[1:], str
    # will be JSON, add leading "_"
    return '_unsupported_' + key, str