code: func (as *AgentState) hasReplace(pUnitName string, pReplaces []string) (found bool, replace string) {
  	for _, eUnit := range as.Units {
  		foundPrepl := false
  		foundErepl := false
  		retStr := ""
  
  		if pUnitName == eUnit.Name {
  			continue
  		}
  
  		for _, pReplace := range pReplaces {
  			if globMatches(pReplace, eUnit.Name) {
  				foundPrepl = true
  				retStr = eUnit.Name
  				break
  			}
  		}
  
  		for _, eReplace := range eUnit.Replaces() {
  			if globMatches(eReplace, pUnitName) {
  				foundErepl = true
  				retStr = eUnit.Name
  				break
  			}
  		}
  
  		// Only 1 of 2 matches must be found. If both matches are found,
  		// it means it's a circular replace situation, which could result in
  		// an infinite loop. So ignore such replace options.
  		if (foundPrepl && foundErepl) || (!foundPrepl && !foundErepl) {
  			continue
  		} else {
  			found = true
  			replace = retStr
  			return
  		}
  	}
  
  	return
  }
docs: // hasReplace determines whether there are any known replaces with the given Unit