code: public static INDArray getAllCandidates(INDArray x,List<RPTree> trees,String similarityFunction) {
          List<Integer> candidates = getCandidates(x,trees,similarityFunction);
          Collections.sort(candidates);
  
          int prevIdx = -1;
          int idxCount = 0;
          List<Pair<Integer,Integer>> scores = new ArrayList<>();
          for(int i = 0; i < candidates.size(); i++) {
              if(candidates.get(i) == prevIdx) {
                  idxCount++;
              }
              else if(prevIdx != -1) {
                  scores.add(Pair.of(idxCount,prevIdx));
                  idxCount = 1;
              }
  
              prevIdx = i;
          }
  
  
          scores.add(Pair.of(idxCount,prevIdx));
  
          INDArray arr = Nd4j.create(scores.size());
          for(int i = 0; i < scores.size(); i++) {
              arr.putScalar(i,scores.get(i).getSecond());
          }
  
          return arr;
      }
docs: Get the search candidates as indices given the input
  and similarity function
  @param x the input data to search with
  @param trees the trees to search
  @param similarityFunction the function to use for similarity
  @return the list of indices as the search results