<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def clean(self, *args, **kwargs):
 """ Check if comments can be inserted for parent node or parent layer """

        # check done only for new nodes!
        if not self.pk:
            node = self.node
            # ensure comments for this node are allowed
            if node.participation_settings.comments_allowed is False:
                raise ValidationError("Comments not allowed for this node")
            # ensure comments for this layer are allowed
            if 'nodeshot.core.layers' in settings.INSTALLED_APPS:
                layer = node.layer
                if layer.participation_settings.comments_allowed is False:
                    raise ValidationError("Comments not allowed for this layer")