When manipulating PDF object trees, you can use these functions to manage indirect references (represented as Python complex numbers in this library, e.g., 0 + 123j for 123 0 R).
Detect all references
deep_ref_detect(obj, l=None) recursively traverses a dictionary or list and returns a set of all complex numbers representing indirect references found in the object tree.
Retarget references
deep_ref_retarget(obj, mapping) recursively traverses an object tree and replaces any complex reference found in the mapping dictionary with its new value.
Replace X, Y, 'R' patterns
replace_ref(tokens) is a utility that converts a specific list pattern [X, Y, 'R'] into a single complex(0, X) object. This is used during parsing to handle the PDF reference syntax.