x = {'a':1, 'b':2, 'c':{'d':3, 'e':4}}

res = [z for k, v in x.items() for z in ([k] if isinstance(v, int) else [[k, ck] for ck in v])]
print(res)