<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def end_grouping(self):
 """ Raises IndexError when no group is open. """

        close = self._open.pop()
        if not close:
            return
        if self._open:
            self._open[-1].extend(close)
        elif self._undoing:
            self._redo.append(close)
        else:
            self._undo.append(close)
        self.notify()