def METHOD_NAME(template, overrides):
    errors = []
    for override, value in sorted(overrides.items()):
        root = template
        override_keys = override.split('.')
        final_key = override_keys.pop()
        intermediate_error = ''
        # Iterate through all but the last key, attempting to find a dictionary at every step
        for i, key in enumerate(override_keys):
            if isinstance(root, dict):
                if i == 0 and root.get('name') == key:
                    continue
                if key in root:
                    root = root[key]
                else:
                    intermediate_error = (
                        f"Template override `{'.'.join(override_keys[:i])}` has no named mapping `{key}`"
                    )
                    break
            elif isinstance(root, list):
                for item in root:
                    if isinstance(item, dict) and item.get('name') == key:
                        root = item
                        break
                else:
                    intermediate_error = (
                        f"Template override `{'.'.join(override_keys[:i])}` has no named mapping `{key}`"
                    )
                    break
            else:
                intermediate_error = (
                    f"Template override `{'.'.join(override_keys[:i])}` does not refer to a mapping"
                )
                break
        if intermediate_error:
            errors.append(intermediate_error)
            continue
        # Force assign the desired value to the final key
        if isinstance(root, dict):
            root[final_key] = value
        elif isinstance(root, list):
            for i, item in enumerate(root):
                if isinstance(item, dict) and item.get('name') == final_key:
                    root[i] = value
                    break
            else:
                intermediate_error = 'Template override has no named mapping `{}`'.format(
                    '.'.join(override_keys) if override_keys else override
                )
        else:
            intermediate_error = 'Template override `{}` does not refer to a mapping'.format(
                '.'.join(override_keys) if override_keys else override
            )
        if intermediate_error:
            errors.append(intermediate_error)
            continue
        overrides.pop(override)
    return errors