def _setup_intersection_dict(loops, annotationmaps, thresholds, margins):
    """
    Sets up the nested dict structure for the intersection dict. See
    ``lib5c.enrichment.make_intersection_dict()``.
    """
    intersection_dict = {}
    for annotation_a in annotationmaps.keys():
        intersection_dict[annotation_a] = {}
        for annotation_b in annotationmaps.keys():
            intersection_dict[annotation_a][annotation_b] = {}
            for loop_type in loops.keys():
                intersection_dict[annotation_a][annotation_b][loop_type] = {}
                for threshold in thresholds:
                    intersection_dict[annotation_a][annotation_b][loop_type][
                        threshold] = {}
                    for margin in margins:
                        intersection_dict[annotation_a][annotation_b][loop_type
                            ][threshold][margin] = {}
    return intersection_dict
