def walk(fn, obj, *args, **kwargs):
if type(obj) in [list, tuple]:<EOL><INDENT>return list(walk(fn, o, *args) for o in obj)<EOL><DEDENT>if type(obj) is dict:<EOL><INDENT>return dict((walk(fn, k, *args), walk(fn, v, *args)) for k, v in<EOL>obj.items())<EOL><DEDENT>return fn(obj, *args, **kwargs)<EOL>
Recursively walk an object graph applying `fn`/`args` to objects.