'Iterate each element and its mapper in an object graph,
for all relationships that meet the given cascade rule.
:param type_:
The name of the cascade rule (i.e. save-update, delete,
etc.)
:param state:
The lead InstanceState.  child items will be processed per
the relationships defined for this object\'s mapper.
the return value are object instances; this provides a strong
reference so that they don\'t fall out of scope immediately.'

def cascade_iterator(self, type_, state, halt_on=None):

    visited_states = set()
    (prp, mpp) = (object(), object())
    visitables = deque([(deque(self._props.values()), prp, state, state.dict)])
    while visitables:
        (iterator, item_type, parent_state, parent_dict) = visitables[(-1)]
        if (not iterator):
            visitables.pop()
            continue
        if (item_type is prp):
            prop = iterator.popleft()
            if (type_ not in prop.cascade):
                continue
            queue = deque(prop.cascade_iterator(type_, parent_state, parent_dict, visited_states, halt_on))
            if queue:
                visitables.append((queue, mpp, None, None))
        elif (item_type is mpp):
            (instance, instance_mapper, corresponding_state, corresponding_dict) = iterator.popleft()
            (yield (instance, instance_mapper, corresponding_state, corresponding_dict))
            visitables.append((deque(instance_mapper._props.values()), prp, corresponding_state, corresponding_dict))
