diff --git a/README.md b/README.md
index 05692ff..334c9e6 100644
--- a/README.md
+++ b/README.md
@@ -133,6 +133,26 @@ Visits each [node](#nodes) in the quadtree in pre-order traversal, invoking the
If the *callback* returns true for a given node, then the children of that node are not visited; otherwise, all child nodes are visited. This can be used to quickly visit only parts of the tree, for example when using the [Barnes–Hut approximation](https://en.wikipedia.org/wiki/Barnes–Hut_simulation). Note, however, that child quadrants are always visited in sibling order: top-left, top-right, bottom-left, bottom-right. In cases such as [search](#quadtree_find), visiting siblings in a specific order may be faster.
+As an example, the following visits the quadtree and returns all the nodes within a rectangular extent [xmin, ymin, xmax, ymax], ignoring quads that cannot possibly contain any such node:
+
+```js
+function search(quadtree, xmin, ymin, xmax, ymax) {
+ const results = [];
+ quadtree.visit(function(node, x1, y1, x2, y2) {
+ if (!node.length) {
+ do {
+ var d = node.data;
+ if (d[0] >= xmin && d[0] < xmax && d[1] >= ymin && d[1] < ymax) {
+ results.push(d);
+ }
+ } while (node = node.next);
+ }
+ return x1 >= xmax || y1 >= ymax || x2 < xmin || y2 < ymin;
+ });
+ return results;
+}
+```
+
# quadtree.visitAfter(callback)
[<>](https://github.com/d3/d3-quadtree/blob/master/src/visitAfter.js "Source")