def group_mols_by_container_index(mol_lst):
    """Take a list of MyMol.MyMol objects, and place them in lists according to
    their associated contnr_idx values. These lists are accessed via
    a dictionary, where they keys are the contnr_idx values
    themselves.

    :param mol_lst: The list of MyMol.MyMol objects.
    :type mol_lst: list
    :return: A dictionary, where keys are contnr_idx values and values are
       lists of MyMol.MyMol objects
    :rtype: dict
    """

    # Make the dictionary.
    grouped_results = {}
    for mol in mol_lst:
        if mol is None:
            # Ignore molecules that are None.
            continue

        idx = mol.contnr_idx

        if not idx in grouped_results:
            grouped_results[idx] = []
        grouped_results[idx].append(mol)

    # Remove redundant entries.
    for key in list(grouped_results.keys()):
        grouped_results[key] = list(set(grouped_results[key]))

    return grouped_results