Track visited objects during serialization to prevent stack overflows by getting stuck in endless loops