code: @Nonnull
      public static List<Mapcode> encodeRestrictToCountryISO2(final double latDeg, final double lonDeg,
                                                              @Nonnull final String countryISO2)
              throws IllegalArgumentException {
          checkNonnull("countryISO2", countryISO2);
          final String countryISO3 = Territory.fromCountryISO2(countryISO2).toString();
          final String prefix = countryISO2.toUpperCase() + '-';
          final List<Mapcode> mapcodes = encode(latDeg, lonDeg);
          final List<Mapcode> filtered = new ArrayList<Mapcode>();
          for (final Mapcode mapcode : mapcodes) {
  
              if (mapcode.getTerritory().toString().startsWith(prefix)) {
                  // If the mapcode starts with the ISO 2 code, it's OK.
                  filtered.add(mapcode);
  
              } else if (mapcode.getTerritory().toString().equals(countryISO3)) {
  
                  // Otherwise, if it's the correct country ISO 3 code, it's also OK.
                  filtered.add(mapcode);
              }
          }
          return filtered;
      }
docs: Encode a lat/lon pair to a list of mapcodes, like {@link #encode(double, double)}.
  The result list is limited to those mapcodes that belong to the provided ISO 3166 country code, 2 characters.
  For example, if you wish to restrict the list to Mexican mapcodes, use "MX". This would
  produce a result list of mapcodes with territories that start with "MX-" (note that a
  mapcode that starts with "MEX" is not returned in that case.)
  
  @param latDeg      Latitude, accepted range: -90..90.
  @param lonDeg      Longitude, accepted range: -180..180.
  @param countryISO2 ISO 3166 country code, 2 characters.
  @return Possibly empty, ordered list of mapcode information records, see {@link Mapcode}.
  @throws IllegalArgumentException Thrown if latitude or longitude are out of range, or if the ISO code is invalid.