def cascade_iterator(self, type_, state, dict_,
                         visited_states, halt_on=None):
        # assert type_ in self._cascade

        # only actively lazy load on the 'delete' cascade
        if type_ != 'delete' or self.passive_deletes:
            passive = attributes.PASSIVE_NO_INITIALIZE
        else:
            passive = attributes.PASSIVE_OFF

        if type_ == 'save-update':
            tuples = state.manager[self.key].impl.\
                get_all_pending(state, dict_)

        else:
            tuples = self._value_as_iterable(state, dict_, self.key,
                                             passive=passive)

        skip_pending = type_ == 'refresh-expire' and 'delete-orphan' \
            not in self._cascade

        for instance_state, c in tuples:
            if instance_state in visited_states:
                continue

            if c is None:
                # would like to emit a warning here, but
                # would not be consistent with collection.append(None)
                # current behavior of silently skipping.
                # see [ticket:2229]
                continue

            instance_dict = attributes.instance_dict(c)

            if halt_on and halt_on(instance_state):
                continue

            if skip_pending and not instance_state.key:
                continue

            instance_mapper = instance_state.manager.mapper

            if not instance_mapper.isa(self.mapper.class_manager.mapper):
                raise AssertionError("Attribute '%s' on class '%s' "
                                     "doesn't handle objects "
                                     "of type '%s'" % (
                                         self.key,
                                         self.parent.class_,
                                         c.__class__
                                     ))

            visited_states.add(instance_state)

            yield c, instance_mapper, instance_state, instance_dict
dataset/ETHPy150Open goFrendiAsgard/kokoropy/kokoropy/packages/sqlalchemy/orm/relationships.py/RelationshipProperty.cascade_iterator/original