code: public static boolean matches(TieredIdentity.LocalityTier tier,
        TieredIdentity.LocalityTier otherTier, boolean resolveIpAddress) {
      String otherTierName = otherTier.getTierName();
      if (!tier.getTierName().equals(otherTierName)) {
        return false;
      }
      String otherTierValue = otherTier.getValue();
      if (tier.getValue() != null && tier.getValue().equals(otherTierValue)) {
        return true;
      }
      // For node tiers, attempt to resolve hostnames to IP addresses, this avoids common
      // misconfiguration errors where a worker is using one hostname and the client is using
      // another.
      if (resolveIpAddress) {
        if (Constants.LOCALITY_NODE.equals(tier.getTierName())) {
          try {
            String tierIpAddress = NetworkAddressUtils.resolveIpAddress(tier.getValue());
            String otherTierIpAddress = NetworkAddressUtils.resolveIpAddress(otherTierValue);
            if (tierIpAddress != null && tierIpAddress.equals(otherTierIpAddress)) {
              return true;
            }
          } catch (UnknownHostException e) {
            return false;
          }
        }
      }
      return false;
    }
docs: Locality comparison for wire type locality tiers, two locality tiers matches if both name and
  values are equal, or for the "node" tier, if the node names resolve to the same IP address.
  
  @param tier a wire type locality tier
  @param otherTier a wire type locality tier to compare to
  @param resolveIpAddress whether or not to resolve hostnames to IP addresses for node locality
  @return true if the wire type locality tier matches the given tier