def _MakeFlatToDict(data): """Helper function for C{FlatToDict}. This function is recursively called @param data: The input data as described in C{FlatToDict}, already splitted @returns: The so far converted dict """ if not compat.fst(compat.fst(data)): assert len(data) == 1, \ "not bottom most element, found %d elements, expected 1" % len(data) return compat.snd(compat.fst(data)) keyfn = lambda e: compat.fst(e).pop(0) return dict([(k, _MakeFlatToDict(list(g))) for (k, g) in itertools.groupby(sorted(data), keyfn)])