return answer

def toDict(L):
    answer = {}
answer[L[0][0]] = L[0][1]
for i in L[1:]:
    pk, sk = L[i][0].split('.')
if pk not in answer:
    answer[pk] = []
if sk not in answer[pk][-1]:
    answer[pk][sk] = L[i][1]
else:
    answer[pk].append({sk: L[i][1]})
Как преобразовать MultiDict во вложенный словарь