static boolean hasDuplicateAccountIdOrName(Collection<Account> accounts) {
    if (accounts == null) {
      return false;
    }
    Set<Short> idSet = new HashSet<>();
    Set<String> nameSet = new HashSet<>();
    boolean res = false;
    for (Account account : accounts) {
      if (!idSet.add(account.getId()) || !nameSet.add(account.getName())) {
        logger.debug("Accounts to update have conflicting id or name. Conflicting accountId={} accountName={}",
            account.getId(), account.getName());
        res = true;
        break;
      }
    }
    return res;
  }
Checks if there are duplicate accountId or accountName in the given collection of {@link Account}s.

@param accounts A collection of {@link Account}s to check duplication.
@return {@code true} if there are duplicated accounts in id or name in the given collection of accounts,
                     {@code false} otherwise.
ambry-account/src/main/java/com/github/ambry/account/AccountUtils.java