def deep_ref_detect(obj: Any, l = None) -> set:
    """Recursively detect all references in object tree."""
    if l is None:
        l = set()
    if type(obj) == complex:
        return l.add(obj)
    elif type(obj) == Stream:
            deep_ref_detect(obj['entries'], l)
    elif type(obj) == dict:
        for k in obj:
            deep_ref_detect(obj[k], l)
    elif type(obj) == list:
        for k in range(len(obj)):
            deep_ref_detect(obj[k], l)
    return l
Recursively detect all references in object tree.
pdfsyntax/objects.py