def extend(hub, name, state, sls_ref):
    """
    Resolve the extend statement
    """
    if 'extend' in state:
        ext = state.pop('extend')
        if not isinstance(ext, dict):
            hub.idem.RUNS[name]['errors'].append(
                f'Extension value in SLS "{sls_ref}" is not a dictionary')
            return
        for id_ in ext:
            if not isinstance(ext[id_], dict):
                hub.idem.RUNS[name]['errors'].append(
                    f'Extension ID "{id_}" in SLS "{sls_ref}" is not a dictionary'
                    )
                continue
            if '__sls__' not in ext[id_]:
                ext[id_]['__sls__'] = sls_ref
            for key in list(ext[id_]):
                if key.startswith('_'):
                    continue
                if not isinstance(ext[id_][key], list):
                    continue
                if '.' in key:
                    comps = key.split('.')
                    ext[id_][comps[0]] = ext[id_].pop(key)
                    ext[id_][comps[0]].append(comps[1])
        state.setdefault('__extend__', []).append(ext)
