def flatten_dict(dic, merge_symbol=':'):
    """
    Flattens a tree like dictionary, merging root keys as the 
    concatenation of all branch keys with the specified merge_symbol (str).
    """
    flattened_dict = {}
    for key, val in dic.items():
        if isinstance(val, dict):
            inner_dict = flatten_dict(val)
            flattened_dict.update({key + merge_symbol + k_inner : val_inner \
                    for k_inner, val_inner in inner_dict.items()})
        else:
            flattened_dict.update({key : val})
    return flattened_dict