<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def children_types( record, index, key='refs', stop_types=STOP_TYPES ):
 """Produce dictionary mapping type-key to instances for all children"""

    types = {}
    for child in children( record, index, key, stop_types=stop_types ):
        types.setdefault(child['type'],[]).append( child )
    return types