Handle circular references with class hierarchy