Detect cyclic references to prevent infinite recursion

Prevents panics from stack overflow with a heuristic to detect cycles.
I'm confused by this. I would think dereferencing a pointer would be the *only* thing that adds depth.