def make_feature_dict(feature_sequence):
    """A feature dict is a convenient way to organize a sequence of Feature
    object (which you have got, e.g., from parse_GFF).

    The function returns a dict with all the feature types as keys. Each value
    of this dict is again a dict, now of feature names. The values of this dict
    is a list of feature.

    An example makes this clear. Let's say you load the C. elegans GTF file
    from Ensemble and make a feature dict:

    >>> worm_features_dict = HTSeq.make_feature_dict(HTSeq.parse_GFF(
    ...     "test_data/Caenorhabditis_elegans.WS200.55.gtf.gz"))

    (This command may take a few minutes to deal with the 430,000 features
    in the GTF file. Note that you may need a lot of RAM if you have millions
    of features.)

    Then, you can simply access, say, exon 0 of gene "F08E10.4" as follows:
    >>> worm_features_dict[ 'exon' ][ 'F08E10.4' ][ 0 ]
    <GenomicFeature: exon 'F08E10.4' at V: 17479353 -> 17479001 (strand '-')>
    """

    res = {}
    for f in feature_sequence:
        if f.type not in res:
            res[f.type] = {}
        res_ftype = res[f.type]
        if f.name not in res_ftype:
            res_ftype[f.name] = [f]
        else:
            res_ftype[f.name].append(f)
    return res