protected VisitResult visit(NR parent, NR node, Q query, TreeRecordVisitor visitor,
			boolean ordered) {
		QueryInclusion inclusion =
			query == null ? QueryInclusion.ALL : query.testNode(node.getShape());
		VisitResult r = visitor.beginNode(parent, node, inclusion);
		if (r != VisitResult.DESCEND) {
			return r;
		}
		if (node.getType().isLeaf()) {
			List<DR> data = new ArrayList<>(getDataChildrenOf(node));
			if (query != null && ordered) {
				data.sort(Comparator.comparing(DR::getBounds, query.getBoundsComparator()));
			}
			for (DR d : data) {
				if (query != null && ordered && query.terminateEarlyData(d.getShape())) {
					break;
				}
				boolean included = query == null || query.testData(d.getShape());
				r = visitor.visitData(node, d, included);
				if (r == VisitResult.ASCEND) {
					return visitor.endNode(parent, node, inclusion);
				}
				if (r == VisitResult.TERMINATE) {
					visitor.endNode(parent, node, inclusion);
					return r;
				}
			}
			return visitor.endNode(parent, node, inclusion);
		}
		assert node.getType().isDirectory();
		List<NR> nodes = new ArrayList<>(getNodeChildrenOf(node));
		if (query != null && ordered) {
			nodes.sort(Comparator.comparing(NR::getBounds, query.getBoundsComparator()));
		}
		for (NR n : nodes) {
			if (query != null && ordered && query.terminateEarlyNode(n.getShape())) {
				break;
			}
			r = visit(node, n, query, visitor, ordered);
			if (r == VisitResult.ASCEND) {
				return visitor.endNode(parent, node, inclusion);
			}
			if (r == VisitResult.TERMINATE) {
				visitor.endNode(parent, node, inclusion);
				return r;
			}
		}
		return visitor.endNode(parent, node, inclusion);
	}
Called when a node is finished being visited.

This only applies to nodes into which the visitor descends. The visitor will finish a
node in one of three ways: 1) The node's children have all been visited. 2) The visitor
returned {@link VisitResult#TERMINATE} while visiting a descendant. 3) The visitor
returned {@link VisitResult#ASCEND} while visiting a child.

This method may return any result except {@link VisitResult#DESCEND}. If the visitor is
terminating, the return value of this method is ignored.

@param parent the parent of this node, or {@code null} when visiting the root
@param n the node currently being visited
@param inclusion the original inclusion of the query before descending
@return a directive for how the visitor should proceed
Ghidra/Debug/ProposedUtils/src/main/java/ghidra/util/database/spatial/AbstractConstraintsTree.java