code: def guard_cancel(analysis_request):
      
      # Ask to partitions
      for partition in analysis_request.getDescendants(all_descendants=False):
          if not isTransitionAllowed(partition, "cancel"):
              return False
  
      # Look through analyses. We've checked the partitions already, so there is
      # no need to look through analyses from partitions again, but through the
      # analyses directly bound to the current Analysis Request.
      cancellable_states = ["unassigned", "registered"]
      for analysis in analysis_request.objectValues("Analysis"):
          if api.get_workflow_status_of(analysis) not in cancellable_states:
              return False
  
      return True
docs: Returns whether 'cancel' transition can be performed or not. Returns
      True only if all analyses are in "unassigned" status