def move_page_links_to_recommended_articles():
    '''
    Derived from https://github.com/wagtail/wagtail/issues/2110
    '''
    articles = ArticlePage.objects.all()

    for article in articles:
        (remaining_blocks, linked_article_blocks) = seperate_end_page_links(
            article.body.stream_data)

        if linked_article_blocks:
            linked_article_ids = get_page_ids_from_page_blocks(
                linked_article_blocks)
            linked_articles = get_pages_from_id_list(linked_article_ids)
            create_recomended_articles(article, linked_articles)
            parent = article.get_parent().specific
            parent.enable_recommended_section = True
            parent.save()

        stream_block = article.body.stream_block
        article.body = StreamValue(stream_block,
                                   remaining_blocks,
                                   is_lazy=True)
        article.save()
Derived from https://github.com/wagtail/wagtail/issues/2110