Translate a table to a hierarchical dictionary?
If you ever only access H[A][B][C] (that is, never H[A] oder H[A][B] alone), I'd suggest a IMO cleaner solution: Use Tuples as defaultdict Index:
from collections import defaultdict
h = defaultdict(list)
for a, b, c, value in input:
h[a, b, c].append(value)
input = [('A1', 'B1', 'C1', 'Value'), (...)]
from collections import defaultdict
tree = defaultdict(lambda: defaultdict(lambda: defaultdict(list)))
#Alternatively you could use partial() rather than lambda:
#tree = defaultdict(partial(defaultdict, partial(defaultdict, list)))
for x, y, z, value in input:
tree[x][y][z].append(value)