def end_container(self, cancel=None):
        """Finishes and registers the currently-active container, unless
        'cancel' is True."""
        if not self._containers:
            return
        container = self._containers.pop()
        if len(self._containers) >= 1:
            parent = self._containers[-1]
        else:
            parent = self._doc.text
        if not cancel:
            parent.addElement(container)
Finishes and registers the currently-active container, unless
        'cancel' is True.
ipymd/lib/opendocument.py