def _load_headlines(docids, fetcher):
    """
    Load the headlines of documents from the `fetcher` with the given IDs.
    :param docids: IDs of the documents to load
    :param fetcher: data fetcher to load the document headlines with
    :return: a dictionary mapping the given document IDs to their respective headlines
    """
    if len(docids) == 0:
        raise ValueError('No document IDs given.')

    old_names_only = fetcher.names_only
    fetcher.names_only = True

    docids = list(sorted(set(docids)))
    headlines = []
    doc_pos = 0

    for doc_id, document in enumerate(fetcher):
        if doc_id == docids[doc_pos]:
            headlines.append(document.name)
            doc_pos += 1

        if doc_pos == len(docids):
            break

    fetcher.names_only = old_names_only
    return dict(zip(docids, headlines))