'Apply the edit \'cmd\' to this object.'

def _do_edit(self, cmd, ctab=None):

    (ctype, line, col, text) = cmd
    assert (('\n' not in text) or (text == '\n'))
    pos = Position(line, col)
    to_kill = set()
    new_cmds = []
    for child in self._children:
        if (ctype == 'I'):
            if ((child._start < pos < Position(child._end.line, child._end.col)) and isinstance(child, NoneditableTextObject)):
                to_kill.add(child)
                new_cmds.append(cmd)
                break
            elif ((child._start <= pos <= child._end) and isinstance(child, EditableTextObject)):
                if ((pos == child.end) and (not child.children)):
                    try:
                        if (ctab.number != child.number):
                            continue
                    except AttributeError:
                        pass
                child._do_edit(cmd, ctab)
                return
        else:
            delend = ((pos + Position(0, len(text))) if (text != '\n') else Position((line + 1), 0))
            if ((child._start <= pos < child._end) and (child._start < delend <= child._end)):
                if isinstance(child, NoneditableTextObject):
                    to_kill.add(child)
                    new_cmds.append(cmd)
                    break
                else:
                    child._do_edit(cmd, ctab)
                    return
            elif (((pos < child._start) and (child._end <= delend) and (child.start < delend)) or ((pos <= child._start) and (child._end < delend))):
                to_kill.add(child)
                new_cmds.append(cmd)
                break
            elif ((pos < child._start) and (child._start < delend <= child._end)):
                my_text = text[:(child._start - pos).col]
                c_text = text[(child._start - pos).col:]
                new_cmds.append((ctype, line, col, my_text))
                new_cmds.append((ctype, line, col, c_text))
                break
            elif ((delend >= child._end) and (child._start <= pos < child._end)):
                c_text = text[(child._end - pos).col:]
                my_text = text[:(child._end - pos).col]
                new_cmds.append((ctype, line, col, c_text))
                new_cmds.append((ctype, line, col, my_text))
                break
    for child in to_kill:
        self._del_child(child)
    if len(new_cmds):
        for child in new_cmds:
            self._do_edit(child)
        return
    delta = (Position(1, 0) if (text == '\n') else Position(0, len(text)))
    if (ctype == 'D'):
        if (self._start == self._end):
            return
        delta.line *= (-1)
        delta.col *= (-1)
    pivot = Position(line, col)
    idx = (-1)
    for (cidx, child) in enumerate(self._children):
        if (child._start < pivot <= child._end):
            idx = cidx
    self._child_has_moved(idx, pivot, delta)
