Pull the extend data and add it to the respective high data

def reconcile_extend(self, high):
        '''
        Pull the extend data and add it to the respective high data
        '''
        errors = []
        if '__extend__' not in high:
            return high, errors
        ext = high.pop('__extend__')
        for ext_chunk in ext:
            for name, body in six.iteritems(ext_chunk):
                if name not in high:
                    state_type = next(
                        x for x in body if not x.startswith('__')
                    )
                    # Check for a matching 'name' override in high data
                    ids = find_name(name, state_type, high)
                    if len(ids) != 1:
                        errors.append(
                            'Cannot extend ID \'{0}\' in \'{1}:{2}\'. It is not '
                            'part of the high state.\n'
                            'This is likely due to a missing include statement '
                            'or an incorrectly typed ID.\nEnsure that a '
                            'state with an ID of \'{0}\' is available\nin '
                            'environment \'{1}\' and to SLS \'{2}\''.format(
                                name,
                                body.get('__env__', 'base'),
                                body.get('__sls__', 'base'))
                            )
                        continue
                    else:
                        name = ids[0][0]

                for state, run in six.iteritems(body):
                    if state.startswith('__'):
                        continue
                    if state not in high[name]:
                        high[name][state] = run
                        continue
                    # high[name][state] is extended by run, both are lists
                    for arg in run:
                        update = False
                        for hind in range(len(high[name][state])):
                            if isinstance(arg, six.string_types) and isinstance(high[name][state][hind], six.string_types):
                                # replacing the function, replace the index
                                high[name][state].pop(hind)
                                high[name][state].insert(hind, arg)
                                update = True
                                continue
                            if isinstance(arg, dict) and isinstance(high[name][state][hind], dict):
                                # It is an option, make sure the options match
                                argfirst = next(iter(arg))
                                if argfirst == next(iter(high[name][state][hind])):
                                    # If argfirst is a requisite then we must merge
                                    # our requisite with that of the target state
                                    if argfirst in STATE_REQUISITE_KEYWORDS:
                                        high[name][state][hind][argfirst].extend(arg[argfirst])
                                    # otherwise, its not a requisite and we are just extending (replacing)
                                    else:
                                        high[name][state][hind] = arg
                                    update = True
                                if (argfirst == 'name' and
                                    next(iter(high[name][state][hind])) == 'names'):
                                    # If names are overwritten by name use the name
                                    high[name][state][hind] = arg
                        if not update:
                            high[name][state].append(arg)
        return high, errors