def _GenericRetrieve(root, default, path):
 if (not root):
  return default
 if (not path):
  return root
 return _GenericRetrieve(root.get(path[0]), default, path[1:])

def _GenericRetrieve ( root , default , path ) : if ( not root ) : return default if ( not path ) : return root return _GenericRetrieve ( root . get ( path [ 0 ] ) , default , path [ 1 : ] )
given a list of dictionary keys |path| and a tree of dicts |root| .