def element_to_nucleotide_colors(bg, element_colors):
    """
    Convert a dictionary of per-element colors to a dictionary of per-nucleotide colors

    :param element_colors: A dictionary of element colors (e.g. {'i0': (255,0,0), 'm1': {255,255,255)}
    :return: A dictionary of nucleotide numbers: (e.g {1: (14,15,120), 2: (255,255,255)})
    """
    new_dict = {}
    for key in element_colors:
        for res in bg.define_residue_num_iterator(key):
            new_dict[res] = element_colors[key]
    return new_dict
