Generate code to implement Trace trait on structures.
Cyclic garbage collection inspired by CPython's gc implementation.