Collection<Point> query(Rect r, Collection<Point> relevantPoints) {
    //could also be a circle instead of a rectangle
    if (this.boundary.intersects(r)) {
      this.points
          .values()
          .stream()
          .filter(r::contains)
          .forEach(relevantPoints::add);
      if (this.divided) {
        this.northwest.query(r, relevantPoints);
        this.northeast.query(r, relevantPoints);
        this.southwest.query(r, relevantPoints);
        this.southeast.query(r, relevantPoints);
      }
    }
    return relevantPoints;
  }
@Test
  void queryTest() {
    var points = new ArrayList<Point>();
    var rand = new Random();
    for (int i = 0; i < 20; i++) {
      var p = new Bubble(rand.nextInt(300), rand.nextInt(300), i, rand.nextInt(2) + 1);
      points.add(p);
    }
    var field = new Rect(150, 150, 300, 300); //size of field
    var queryRange = new Rect(70, 130, 100, 100); //result = all points lying in this rectangle
    //points found in the query range using quadtree and normal method is same
    var points1 = QuadTreeTest.quadTreeTest(points, field, queryRange);
    var points2 = QuadTreeTest.verify(points, queryRange);
    assertEquals(points1, points2);
  }