code: function lookupCountryByIdShouldBeCalled(q) {
    // helper that returns true if at least one Hierarchy of a result has a `country_id` property
    var hasCountryId = function(result) {
      return _.some(result.Hierarchy, (h) => { return h.hasOwnProperty('country_id');});
    };
  
    // don't call if no (or any) result has a country id
    if (!_.some(q.results, hasCountryId)) {
      return false;
    }
  
    // don't call lookupCountryById if it's already been called
    if (q.lookupCountryByIdHasBeenCalled) {
      return false;
    }
  
    // return true if there are no results with 'country' Placetype
    return !_.some(q.results, (result) => { return result.Placetype === 'country'; } );
  
  }
docs: helper function to determine if country should be looked up by id returns `false` if: 1.  there are no results (lat/lon is in the middle of an ocean) 2.  no result has a hierarchy country id (shouldn't happen but guard against bad data) 3.  lookupCountryByIdHasBeenCalled has already been called 4.  there is already a result with a `country` Placetype  in the general case, this function should return true because the country polygon lookup is normally skipped for performance reasons but country needs to be looked up anyway