def dict_depth(d, depth):
    ret = depth
for i in list(d.keys()):
    if type(d[i]) is dict:
        newDict = d[i]
ret = max(dict_depth(newDict, depth + 1), ret)
return ret
Рекурсивная глубина словаря Python