def _get_copied_state_name(self, current_name: str):
        """
        Get a non-duplicating name for the copied state.

        :param str current_name:    The current name of the state.
        :return:                    A new name of the copied state.
        :rtype:                     str
        """

        m = re.match(r"^([\s\S]*) copy\s*(\d*)$", current_name)

        if m:
            # ends with copy
            ctr_str = m.group(2)
            ctr = int(ctr_str) + 1 if ctr_str else 1

            current_name = m.group(1)
            name = f"{current_name} copy {ctr}"
        else:
            ctr = 0
            name = current_name + " copy"

        # Increment the counter until there is no conflict with existing names
        all_names = {s.gui_data.name for s in self.states}
        while name in all_names:
            ctr += 1
            name = f"{current_name} copy {ctr}"
        return name

        Get a non-duplicating name for the copied state.

        :param str current_name:    The current name of the state.
        :return:                    A new name of the copied state.
        :rtype:                     str
        
angrmanagement/ui/widgets/qstate_table.py