def duplicate(self, new_parent=None):
kwargs = {}<EOL>for spec_name, spec in list(self._meta.specs.items()):<EOL><INDENT>value = getattr(self, spec_name)<EOL>if isinstance(value, Color):<EOL><INDENT>print("<STR_LIT>", value, value.default)<EOL>if value.default:<EOL><INDENT>value = None<EOL><DEDENT><DEDENT>if value is not None:<EOL><INDENT>kwargs[spec_name] = value<EOL><DEDENT><DEDENT>del kwargs['<STR_LIT>'] <EOL>new_id = wx.NewId()<EOL>kwargs['<STR_LIT:id>'] = new_id<EOL>kwargs['<STR_LIT:name>'] = "<STR_LIT>" % (kwargs['<STR_LIT:name>'], new_id)<EOL>new_obj = self.__class__(new_parent or self.get_parent(), **kwargs)<EOL>for child in self:<EOL><INDENT>child.duplicate(new_obj)<EOL><DEDENT>return new_obj<EOL>
Create a new object exactly similar to self