code: func findHistory(toRevision int64, allHistory []*appsv1.ControllerRevision) *appsv1.ControllerRevision {
  	if toRevision == 0 && len(allHistory) <= 1 {
  		return nil
  	}
  
  	// Find the history to rollback to
  	var toHistory *appsv1.ControllerRevision
  	if toRevision == 0 {
  		// If toRevision == 0, find the latest revision (2nd max)
  		sort.Sort(historiesByRevision(allHistory))
  		toHistory = allHistory[len(allHistory)-2]
  	} else {
  		for _, h := range allHistory {
  			if h.Revision == toRevision {
  				// If toRevision != 0, find the history with matching revision
  				return h
  			}
  		}
  	}
  
  	return toHistory
  }
docs: // findHistory returns a controllerrevision of a specific revision from the given controllerrevisions.
  // It returns nil if no such controllerrevision exists.
  // If toRevision is 0, the last previously used history is returned.