Given a tuple, it creates a tree with nested dictionaries and then finally the respective counts for the sequence for the number of times it appears.
dct = {}
incr_dict(dct, ('a', 'b', 'c'))
dct # {'a': {'b': {'c': 1}}}
incr_dict(dct, ('a', 'b', 'c'))
dct # {'a': {'b': {'c': 2}}}
incr_dict(dct, ('a', 'b', 'f'))
dct # {'a': {'b': {'c': 2, 'f': 1}}}
incr_dict(dct, ('a', 'r', 'f'))
dct # {'a': {'r': {'f': 1}, 'b': {'c': 2, 'f': 1}}}
incr_dict(dct, ('a', 'z'))
dct # {'a': {'r': {'f': 1}, 'b': {'c': 2,'f': 1}, 'z': 1}}