code: func getLocalCachedImage(imageStore image.Store, imgID image.ID, config *containertypes.Config) (*image.Image, error) {
  	// Loop on the children of the given image and check the config
  	getMatch := func(siblings []image.ID) (*image.Image, error) {
  		var match *image.Image
  		for _, id := range siblings {
  			img, err := imageStore.Get(id)
  			if err != nil {
  				return nil, fmt.Errorf("unable to find image %q", id)
  			}
  
  			if compare(&img.ContainerConfig, config) {
  				// check for the most up to date match
  				if match == nil || match.Created.Before(img.Created) {
  					match = img
  				}
  			}
  		}
  		return match, nil
  	}
  
  	// In this case, this is `FROM scratch`, which isn't an actual image.
  	if imgID == "" {
  		images := imageStore.Map()
  		var siblings []image.ID
  		for id, img := range images {
  			if img.Parent == imgID {
  				siblings = append(siblings, id)
  			}
  		}
  		return getMatch(siblings)
  	}
  
  	// find match from child images
  	siblings := imageStore.Children(imgID)
  	return getMatch(siblings)
  }
docs: // getLocalCachedImage returns the most recent created image that is a child
  // of the image with imgID, that had the same config when it was
  // created. nil is returned if a child cannot be found. An error is
  // returned if the parent image cannot be found.