docs: int getIntersectionCount(Envelope2D query, double tolerance, int max_count) {
  		if (m_root == -1)
  			return 0;
  
  		Envelope2D query_inflated = new Envelope2D();
  		query_inflated.setCoords(query);
  		query_inflated.inflate(tolerance, tolerance);
  
  		AttributeStreamOfInt32 quads_stack = new AttributeStreamOfInt32(0);
  		ArrayList<Envelope2D> extents_stack = new ArrayList<Envelope2D>(0);
  		quads_stack.add(m_root);
  		extents_stack.add(new Envelope2D(m_extent.xmin, m_extent.ymin, m_extent.xmax, m_extent.ymax));
  
  		Envelope2D[] child_extents = new Envelope2D[4];
  		child_extents[0] = new Envelope2D();
  		child_extents[1] = new Envelope2D();
  		child_extents[2] = new Envelope2D();
  		child_extents[3] = new Envelope2D();
  
  		Envelope2D current_extent = new Envelope2D();
  
  		int intersection_count = 0;
  
  		while (quads_stack.size() > 0) {
  			boolean b_subdivide = false;
  
  			int current_quad_handle = quads_stack.getLast();
  			current_extent.setCoords(extents_stack.get(extents_stack.size() - 1));
  
  			quads_stack.removeLast();
  			extents_stack.remove(extents_stack.size() - 1);
  
  
  			if (query_inflated.contains(current_extent)) {
  				intersection_count += getSubTreeElementCount(current_quad_handle);
  
  				if (max_count > 0 && intersection_count >= max_count)
  					return max_count;
  			} else {
  				if (query_inflated.isIntersecting(current_extent)) {
  					for (int element_handle = get_first_element_(current_quad_handle); element_handle != -1; element_handle = get_next_element_(element_handle)) {
  						int data_handle = get_data_(element_handle);
  						Envelope2D env = get_bounding_box_value_(data_handle);
  
  						if (env.isIntersecting(query_inflated)) {
  							intersection_count++;
  
  							if (max_count > 0 && intersection_count >= max_count)
  								return max_count;
  						}
  					}
  
  					b_subdivide = getHeight(current_quad_handle) + 1 <= m_height;
  				}
  			}
  
  			if (b_subdivide) {
  				set_child_extents_(current_extent, child_extents);
  
  				for (int i = 0; i < 4; i++) {
  					int child_handle = get_child_(current_quad_handle, i);
  
  					if (child_handle != -1 && getSubTreeElementCount(child_handle) > 0) {
  						boolean b_is_intersecting = query_inflated.isIntersecting(child_extents[i]);
  
  						if (b_is_intersecting) {
  							quads_stack.add(child_handle);
  							extents_stack.add(new Envelope2D(child_extents[i].xmin, child_extents[i].ymin, child_extents[i].xmax, child_extents[i].ymax));
  						}
  					}
  				}
  			}
  		}
  
  		return intersection_count;
  	}