code: private int calculateSuggestionItemsHeight(List<? extends SearchSuggestion> suggestions, int max) {
  
          //todo
          // 'i < suggestions.size()' in the below 'for' seems unneeded, investigate if there is a use for it.
          int visibleItemsHeight = 0;
          for (int i = 0; i < suggestions.size() && i < mSuggestionsList.getChildCount(); i++) {
              visibleItemsHeight += mSuggestionsList.getChildAt(i).getHeight();
              if (visibleItemsHeight > max) {
                  visibleItemsHeight = max;
                  break;
              }
          }
          return visibleItemsHeight;
      }
docs: results is >= max. The max option allows us to avoid doing unnecessary and potentially long calculations.