from functools import reduce
a = {'b': {'c': {'d': True}}}
reduce(lambda x, y: x and y in x and x[y], ['b', 'c', 'd'], a)
reduce(lambda x, y: x and y in x and x[y], ['b', 'cd', 'd'], a)
Is there a clean test for a dictionary element in Python?