'Updates block_data with any inheritable setting set by an ancestor and recurses to children.'

@contract(block_map='dict(BlockKey:    dict)', block_key=BlockKey)
def inherit_settings(self, block_map, block_key, inherited_settings_map, inheriting_settings=None, inherited_from=None):

    if (block_key not in block_map):
        return
    block_data = block_map[block_key]
    if (inheriting_settings is None):
        inheriting_settings = {}
    if (inherited_from is None):
        inherited_from = []
    inherited_settings_map.setdefault(block_key, {}).update(inheriting_settings)
    inheriting_settings = inherited_settings_map[block_key].copy()
    block_fields = block_data.fields
    for field_name in inheritance.InheritanceMixin.fields:
        if (field_name in block_fields):
            inheriting_settings[field_name] = block_fields[field_name]
    for child in block_fields.get('children', []):
        try:
            if (child in inherited_from):
                raise Exception(u'Infinite    loop    detected    when    inheriting    to    {},    having    already    inherited    from    {}'.format(child, inherited_from))
            self.inherit_settings(block_map, BlockKey(*child), inherited_settings_map, inheriting_settings, (inherited_from + [child]))
        except KeyError:
            pass
