private Node divideTree(int left, int right, BoundingBox bbox) {
		Node node = new Node();

		// If too few objects remain, then make this a leaf node.
		if (right - left <= maxPointsInOneLeafNode) {
			node.child1 = node.child2 = null;
			node.leftObjectIndex = left;
			node.rightObjectIndex = right;

			// Compute bounding box for the objects in this leaf node.
			for (int i = 0; i < numberOfDimensions; i++) {
				double val = data[objectsIndices.get(left)][i];
				bbox.add(val, val);
			}
			for (int k = left + 1; k < right; k++) {
				for (int i = 0; i < numberOfDimensions; i++) {
					double objectKInDimensionI = data[objectsIndices.get(k)][i];
					if (objectKInDimensionI < bbox.getMin(i))
						bbox.setMin(i, objectKInDimensionI);
					if (objectKInDimensionI > bbox.getMax(i))
						bbox.setMax(i, objectKInDimensionI);
				}
			}
		} else {
			middleSplitResult out = new middleSplitResult();
			middleSplit(left, right - left, bbox, out);
			int cutObjectIndex = out.cutObjectIndex;
			int cutDimension = out.cutDimension;
			double cutValue = out.cutDimensionValue;

			node.cutDimension = cutDimension;

			BoundingBox leftBBox = new BoundingBox(bbox);
			leftBBox.setMax(cutDimension, cutValue);
			node.child1 = divideTree(left, left + cutObjectIndex, leftBBox);

			BoundingBox rightBBox = new BoundingBox(bbox);
			rightBBox.setMin(cutDimension, cutValue);
			node.child2 = divideTree(left + cutObjectIndex, right, rightBBox);

			node.cutDimensionLow = leftBBox.getMax(cutDimension);
			node.cutDimensionHigh = rightBBox.getMin(cutDimension);

			for (int i = 0; i < numberOfDimensions; ++i) {
				bbox.setMin(i,
						Math.min(leftBBox.getMin(i), rightBBox.getMin(i)));
				bbox.setMax(i,
						Math.max(leftBBox.getMax(i), rightBBox.getMax(i)));
			}
		}

		return node;
	}