'does the work for clearstamp() and clearstamps()'

def _clearstamp(self, stampid):

    if (stampid in self.stampItems):
        if isinstance(stampid, tuple):
            for subitem in stampid:
                self.screen._delete(subitem)
        else:
            self.screen._delete(stampid)
        self.stampItems.remove(stampid)
    item = ('stamp', stampid)
    buf = self.undobuffer
    if (item not in buf.buffer):
        return
    index = buf.buffer.index(item)
    buf.buffer.remove(item)
    if (index <= buf.ptr):
        buf.ptr = ((buf.ptr - 1) % buf.bufsize)
    buf.buffer.insert(((buf.ptr + 1) % buf.bufsize), [None])
