def _GetFailedStepsForEachCL(analysis):
  """Gets suspected CLs and their corresponding failed steps."""
  suspected_cl_steps = {}
  if (analysis is None or analysis.result is None or
      not analysis.result['failures']):
    return suspected_cl_steps

  for failure in analysis.result['failures']:
    for suspected_cl in failure['suspected_cls']:
      cl_key = suspected_cl['repo_name'] + ',' + suspected_cl['revision']
      if not suspected_cl_steps.get(cl_key):
        suspected_cl_steps[cl_key] = [failure['step_name']]
      else:
        suspected_cl_steps[cl_key].append(failure['step_name'])
  return suspected_cl_steps