code: def undo(self):
          
          if self.grouping_level() == 1:
              self.end_grouping()
          if self._open:
              raise IndexError
          self.undo_nested_group()
          self.notify()
docs: Raises IndexError if more than one group is open, otherwise closes it
          and invokes undo_nested_group.