def copy(self, *args, **kwargs):
        """Copy this model element and contained elements if they exist."""

        for slot in self.__slots__:
            attr = getattr(self, slot)
            if slot[0] == '_':  # convert protected attribute name to public
                slot = slot[1:]
            if slot not in kwargs:
                kwargs[slot] = attr

        result = type(self)(*args, **kwargs)

        return result
Copy this model element and contained elements if they exist.