code: func removeTerminatedContainer(containers []*runtimeapi.Container) []*runtimeapi.Container {
  	containerMap := make(map[containerID][]*runtimeapi.Container)
  	// Sort order by create time
  	sort.Slice(containers, func(i, j int) bool {
  		return containers[i].CreatedAt < containers[j].CreatedAt
  	})
  	for _, container := range containers {
  		refID := containerID{
  			podRef:        buildPodRef(container.Labels),
  			containerName: kubetypes.GetContainerName(container.Labels),
  		}
  		containerMap[refID] = append(containerMap[refID], container)
  	}
  
  	result := make([]*runtimeapi.Container, 0)
  	for _, refs := range containerMap {
  		if len(refs) == 1 {
  			result = append(result, refs[0])
  			continue
  		}
  		found := false
  		for i := 0; i < len(refs); i++ {
  			if refs[i].State == runtimeapi.ContainerState_CONTAINER_RUNNING {
  				found = true
  				result = append(result, refs[i])
  			}
  		}
  		if !found {
  			result = append(result, refs[len(refs)-1])
  		}
  	}
  	return result
  }
docs: // removeTerminatedContainer returns the specified container but with
  // the stats of the terminated containers removed.