Helper to add numbers to slugs

def _clean_page_automatic_slug_renaming(self, slug, is_slug_safe):
        """Helper to add numbers to slugs"""

        if not callable(is_slug_safe):
            raise TypeError('is_slug_safe must be callable')

        if is_slug_safe(slug):
            return slug

        count = 2
        new_slug = slug + "-" + str(count)
        while not is_slug_safe(new_slug):
            count = count + 1
            new_slug = slug + "-" + str(count)
        return new_slug