def decode_msg(coded_msg, code):
    """
    Function that decodes a given text with a given Huffman code for each character.
    The decoding is very simple as the Huffman code is an optimal prefix code.
    :param coded_msg:
    :param code:
    :return: decoed_msg
    """
    decoded_msg = ""
    while coded_msg:
        for key, coding in code.items():
            if coded_msg.startswith(coding):
                decoded_msg += key
                coded_msg = coded_msg[len(coding):]
    return decoded_msg