def memoize_obj_in_cache(idx: list, fdata: Callable, key: int, cache=None, rev=-1) -> list:
    """Parse indirect object whose number is [key] and return a cache filled at index [key].

    cache argument may be:
    - a list that is updated
    - or None that is replaced with an empty list
    """
    if cache is None:
        cache = (key + 1) * [None]
    if 'DELETED' in idx[rev][key]:
        return cache
    if  cache[key] != None:
        return cache
    if key == 0:
        index = idx[rev][key]
        if type(index) != list:
            indexes = [index]
        else:
            indexes = index
        obj = {}
        for index in indexes:
            bdata, a0, _, _ = fdata(index['abs_pos'],
                                    index['abs_next'] - index['abs_pos'])
            i, j, _ = next_token(bdata, a0)
            if bdata[i:j] == b'trailer':
                i, j, _ = next_token(bdata, j)
            else:
                i, j, _ = next_token(bdata, j)
                i, j, _ = next_token(bdata, j)
                i, j, _ = next_token(bdata, j)
            text = bdata
            i_obj = parse_obj(text, i)
            if type(i_obj) == Stream:
                i_obj = i_obj['entries']
            obj.update(i_obj)
        cache[key] = obj    
    elif 'env_num' not in idx[rev][key]:
        bdata, a0, _, _ = fdata(idx[rev][key]['abs_pos'],
                                idx[rev][key]['abs_next'] - idx[rev][key]['abs_pos'])
        i, j, _ = next_token(bdata, a0)
        i, j, _ = next_token(bdata, j)
        i, j, _ = next_token(bdata, j)
        i, j, _ = next_token(bdata, j)
        text = bdata
        obj = parse_obj(text, i)
        if key == 0 and type(obj) == Stream:
            obj = obj['entries']
        cache[key] = obj    
    else:
        container = idx[rev][key]['env_num']
        bdata, a0, _, _ = fdata(idx[rev][container]['abs_pos'],
                                idx[rev][container]['abs_next'] - idx[rev][container]['abs_pos'])
        i, j, _ = next_token(bdata, a0)
        i, j, _ = next_token(bdata, j)
        i, j, _ = next_token(bdata, j)
        i, j, _ = next_token(bdata, j) #/ObjStm
        text = bdata
        stream_obj = parse_obj(text, i)
        if container >= len(cache):
            cache += (container-len(cache)+1) * [None]
        cache[container] = stream_obj
        _, _, _, obj_list = parse_object_stream(stream_obj, container)
        for o_num, embedded_obj, _, _, _ in obj_list:
            if o_num >= len(cache):
                cache += (o_num-len(cache)+1) * [None]
            cache[o_num] = embedded_obj
    return cache
Parse indirect object whose number is [key] and return a cache filled at index [key].

    cache argument may be:
    - a list that is updated
    - or None that is replaced with an empty list
    
pdfsyntax/docstruct.py