def build_links_to_remove(external_download_links, home_pages,
    internal_download_links, unknown_links):
    """
    Generates a list of links to remove based on which links are preferred.

    :param list external_download_links:
        list of internal download links
    :param list home_pages:
        list of home pages
    :param list internal_download_links:
        list of internal download links
    :param list unknown_links:
        list of unknown links, or links that do not match either any of the
        previous three.
    :returns:
        list of :class:`lxml.etree.ElementTree.Element` that are safe to be
        removed.
    """
    if internal_download_links:
        to_be_removed = external_download_links + home_pages + unknown_links
    elif external_download_links:
        to_be_removed = home_pages + unknown_links
    elif home_pages:
        to_be_removed = unknown_links
    else:
        to_be_removed = []
    return to_be_removed
