Return pointers to all GC tracked objects

def get_all_objects(self):
        "Return pointers to all GC tracked objects"
        for i, generation in enumerate(self.gc_generations):
            generation_head_ptr = pygc_head_ptr = generation.head.get_pointer()
            generation_head_addr = generation_head_ptr._value
            while True:
                # _PyObjectBase_GC_UNTRACK macro says that
                # gc_prev always points to some value
                # there is still a race condition if PyGC_Head
                # gets free'd and overwritten just before we look
                # at him
                pygc_head_ptr = pygc_head_ptr.deref().gc_next
                if pygc_head_ptr._value == generation_head_addr:
                    break
                yield pygc_head_ptr.deref().get_object_ptr()