def _rapply(d, func, *args, **kwargs):
if isinstance(d, (tuple, list)):<EOL><INDENT>return [_rapply(each, func, *args, **kwargs) for each in d]<EOL><DEDENT>if isinstance(d, dict):<EOL><INDENT>return {<EOL>key: _rapply(value, func, *args, **kwargs) for key, value in iteritems(d)<EOL>}<EOL><DEDENT>else:<EOL><INDENT>return func(d, *args, **kwargs)<EOL><DEDENT>
Apply a function to all values in a dictionary or list of dictionaries, recursively.