'Extract all children. If decompose is True, decompose instead.'

def clear(self, decompose=False):

    if decompose:
        for element in self.contents[:]:
            if isinstance(element, Tag):
                element.decompose()
            else:
                element.extract()
    else:
        for element in self.contents[:]:
            element.extract()
