function search(quadtree, [[x0, y0], [x3, y3]], scanned, selected) {
scanned.length = 0;
selected.length = 0;
quadtree.visit((node, x1, y1, x2, y2) => {
if (!node.length) {
do {
const {data: d, data: [x, y]} = node;
const test = x >= x0 && x < x3 && y >= y0 && y < y3;
(test ? selected : scanned).push(d)
return test;
} while ((node = node.next));
}
return x1 >= x3 || y1 >= y3 || x2 < x0 || y2 < y0;
});
}