def import_tags(source, target, project_id, collected_tags):
    tags_to_import_now = set([])
    tags_to_import_then = set([])
    for tag in collected_tags:
        if is_prefix_of_any_other_tag(tag, collected_tags):
            tags_to_import_then.add(tag)
        else:
            tags_to_import_now.add(tag)
    last_page = False
    current_page = 1
    while not last_page:
        stories = source.get_stories_for_project(project_id, current_page)
        for story in stories[u'items']:
            if u'tags' in story:
                for tag in [t[u'name'] for t in story[u'tags'] if t[u'name'] in tags_to_import_now]:
                    target.executeCommand("%s-%s" % (project_id, story[u'id']), "tag " + tag)
        current_page += 1
        if current_page > stories[u'totalPages']:
            last_page = True
    if len(tags_to_import_then):
        import_tags(source, target, project_id, tags_to_import_then)
dataset/ETHPy150Open JetBrains/youtrack-rest-python-library/python/agilezen2youtrack.py/import_tags/original