In this example, some points (in red) have been used to build a quadtree. The tree structure is then used to aggregate the number of points in each quad (counts obtained for the first level are displayed).
https://d3js.org/d3.v4.min.js
https://d3js.org/d3-selection-multi.v0.4.min.js