def _pruneLookups(table, deadLookups):
    """Go through the lookup list and remove the lookups that are in the
    deadLookups set. Return a dictionary that maps the old lookup indices to
    the new, for remapping the lookup indices used in features and in other
    lookups."""
    lookupsToDelete = []
    indicesBefore = list(range(len(table.LookupList.Lookup)))
    for lookupIndex, lookup in enumerate(table.LookupList.Lookup):
        subTablesToDelete = []
        for subTableIndex, subTable in enumerate(lookup.SubTable):
            actualSubTable = subTable
            if subTable.__class__.__name__ in ['ExtensionSubst', 'ExtensionPos'
                ]:
                actualSubTable = subTable.ExtSubTable
            if actualSubTable in deadLookups:
                subTablesToDelete.append(subTableIndex)
        for subTableIndex in reversed(subTablesToDelete):
            del lookup.SubTable[subTableIndex]
        lookup.SubTableCount = len(lookup.SubTable)
        if not lookup.SubTable:
            lookupsToDelete.append(lookupIndex)
    for i in reversed(lookupsToDelete):
        del indicesBefore[i]
        del table.LookupList.Lookup[i]
    table.LookupList.LookupCount = len(table.LookupList.Lookup)
    indicesAfter = range(len(indicesBefore))
    lookupRemap = dict(zip(indicesBefore, indicesAfter))
    return lookupRemap
