queryBuilder.location(location.getState()).clearFeatureCodes().addAdminCodes();
for (ResolvedLocation country : countries) {
queryBuilder.addParentIds(country.getGeoname().getGeonameID());
foundCountries.add(country.getGeoname().getPrimaryCountryCode());
}
List<ResolvedLocation> states = gazetteer.getClosestLocations(queryBuilder.build());
// city query should only include city-level feature codes; ancestry is restricted
// to the discovered states or, if no states were found, the discovered countries or,
// if neither states nor countries were found, no ancestry restrictions are added and
// the most populated city will be selected