function query(dim, tree, min, max) {
const points = []
const query = (tree, depth) => {
if (tree == null) return
const ax = depth % dim
if (tree.value[ax] < min[ax]) query(tree.high, depth + 1)
else if (tree.value[ax] > max[ax]) query(tree.low, depth + 1)
else {
if (pointInRange(tree.value, min, max)) points.push(tree.value)
query(tree.low, depth + 1)
query(tree.high, depth + 1)
}
}
query(tree, 0)
return points
}