def recursive_walk(function, data):
  # Recurse into lists.
  if isinstance(data, list):
    return list(recursive_walk(function, val) for val in data)

  # Recurse into dicts:
  if isinstance(data, dict):
    return dict( (key, recursive_walk(function, val)) for key, val in data.iteritems() )

  return function(data)
Recursively processes dicts, lists and tuples, returning a copy
dataset/ETHPy150Open cloudera/hue/desktop/core/src/desktop/lib/parameterization.py/recursive_walk