def deepmap(f, dl):
  """
  Performs a deep map over deeply nested list.
  
  Examples
  --------
  
  Let us define a deep list:
  
  >>> dl = [0, 1, [2, [3], 4]]
  
  Now we can apply the function over each leaf of the list:
  
  >>> deepmap(lambda x: x + 1, dl)  
  [1, 2, [3, [4], 5]]
  """
  if isinstance(dl, list):
    return map(lambda x: deepmap(f, x), dl)
  else:
    return f(dl)