canonicalize: Keep track of the replacement objects so the correct object can be substituted when a circular reference is detected.