def top_block_titles(config, block_type):
    """Extract the set of titles associated with a block type.

    Each top level TRExFitter block has a title and we can extract the
    titles of a specific top level block type.

    Parameters
    ----------
    config : str
        Path of the config file.
    block_type : str
        Block type the titles are associated with.

    Returns
    -------
    set(str)
        Titles of the requested blocks.

    Examples
    --------
    A config with some blocks of the form::

      Region: "reg2j2b"
        Label: "..."
        ShortLabel: "..."
        Selection: "..."
        Binning ...

      Region: "reg2j1b"
        Label: "..."
        ShortLabel: "..."
        Selection: "..."
        Binning ...

    will yield::

      >>> top_block_titles("/path/to/fit.conf", "Region")
      ["reg2j2b", "reg2j1b"]

    """
    with open(config, "r") as f:
        return set(
            map(
                lambda line: line.split(": ")[1].replace('"', "").strip(),
                filter(
                    lambda line: str(line).startswith("%s: " % block_type),
                    f.readlines(),
                ),
            )
        )