def remove_duplicated_colors(self):
        """Remove widgets so each color appears only once."""
        ### reference widget list locally, for quick and
        ### easier access
        widgets = self.widgets

        ### create two sets to keep track of colors we have
        ### already seen and widgets to be removed

        colors_already_seen = set()
        widgets_to_remove = set()

        ### iterate over color widgets, separating for
        ### removal those widgets whose colors have already
        ### been seen

        for widget in widgets:

            color_tuple = tuple(widget.color)

            if color_tuple in colors_already_seen:
                widgets_to_remove.add(widget)

            colors_already_seen.add(color_tuple)

        ### if there are widgets to be removed, try doing so

        if widgets_to_remove:
            self.remove_color_widgets(widgets_to_remove)
Remove widgets so each color appears only once.
nodezator/colorsman/editor/panel/colorsop.py