def _maybe_get_and_apply(dictionary, key, apply_fn):
  """Returns the result of apply_fn on the value of the key if not None."""
  if key not in dictionary:
    return None
  return apply_fn(dictionary[key])