def recursive_map(fn, element, sequence_type=None):
 if (sequence_type is None):
  return recursive_map(fn, element, type(element))
 elif isinstance(element, sequence_type):
  return map((lambda x: recursive_map(fn, x, sequence_type)), element)
 else:
  return fn(element)

def recursive_map ( fn , element , sequence_type = None ) : if ( sequence_type is None ) : return recursive_map ( fn , element , type ( element ) ) elif isinstance ( element , sequence_type ) : return map ( ( lambda x : recursive_map ( fn , x , sequence_type ) ) , element ) else : return fn ( element )
maps a tree-like data structure built by composing sequences of type iterable_type .