def circular_deleted(changes: list) -> dict:
    """Build lookup dict to ref of next deleted object."""
    res = {}
    deleted = [x for x in changes if x[1] == 'd']
    for i, d in enumerate([(0j, 'd')] + deleted):
        e = int(d[0].imag)
        if i == len(deleted):
            res[e] = 0
        else:
            t = deleted[i][0]
            res[e] = int(t.imag)
    return res
Build lookup dict to ref of next deleted object.
pdfsyntax/filestruct.py