code: func getAncestry(file *os.File, imgID string, debug log.Logger) ([]string, error) {
  	var ancestry []string
  	deps := make(map[string]bool)
  
  	curImgID := imgID
  
  	var err error
  	for curImgID != "" {
  		if deps[curImgID] {
  			return nil, fmt.Errorf("dependency loop detected at image %q", curImgID)
  		}
  		deps[curImgID] = true
  		ancestry = append(ancestry, curImgID)
  		debug.Printf("Getting ancestry for layer %q", curImgID)
  		curImgID, err = getParent(file, curImgID, debug)
  		if err != nil {
  			return nil, err
  		}
  	}
  	return ancestry, nil
  }
docs: // getAncestry computes an image ancestry, returning an ordered list
  // of dependencies starting from the topmost image to the base.
  // It checks for dependency loops via duplicate detection in the image
  // chain and errors out in such cases.