code: public static INDArray queryAll(INDArray toQuery,INDArray X,List<RPTree> trees,int n,String similarityFunction) {
          if(trees.isEmpty()) {
              throw new ND4JIllegalArgumentException("Trees is empty!");
          }
  
          List<Integer> candidates = getCandidates(toQuery, trees,similarityFunction);
          val sortedCandidates = sortCandidates(toQuery,X,candidates,similarityFunction);
          int numReturns = Math.min(n,sortedCandidates.size());
  
          INDArray result = Nd4j.create(numReturns);
          for(int i = 0; i < numReturns; i++) {
              result.putScalar(i,sortedCandidates.get(i).getSecond());
          }
  
  
          return result;
      }
docs: Query all trees using the given input and data
  @param toQuery the query vector
  @param X the input data to query
  @param trees the trees to query
  @param n the number of results to search for
  @param similarityFunction the similarity function to use
  @return the indices (in order) in the ndarray