// Path: src/main/java/com/github/davidmoten/rtree3d/geometry/Geometry.java
// public interface Geometry {
// 
//     /**
//      * <p>
//      * Returns the distance to the given {@link Box}. For a
//      * {@link Box} this might be Euclidean distance but for an EPSG4326
//      * lat-long Rectangle might be great-circle distance. The distance function
//      * should satisfy the following properties:
//      * </p>
//      * 
//      * <p>
//      * <code>distance(r) &gt;= 0</code>
//      * </p>
//      * 
//      * <p>
//      * <code>if r1 contains r2 then distance(r1)&lt;=distance(r2)</code>
//      * </p>
//      * 
//      * 
//      * @param r
//      *            rectangle to measure distance to
//      * @return distance to the rectangle r from the geometry
//      */
//     double distance(Box r);
// 
//     /**
//      * Returns the minimum bounding rectangle of this geometry.
//      * 
//      * @return minimum bounding rectangle
//      */
//     Box mbb();
// 
//     boolean intersects(Box r);
// }


import rx.Subscriber;
import rx.functions.Func1;
import com.github.davidmoten.rtree3d.geometry.Geometry;
import com.github.davidmoten.util.ImmutableStack;
package com.github.davidmoten.rtree3d;



/**
 * Utility methods for controlling backpressure of the tree search.
 */
final class Backpressure {

    private Backpressure() {
        // prevent instantiation
    }

// Path: src/main/java/com/github/davidmoten/rtree3d/geometry/Geometry.java
// public interface Geometry {
// 
//     /**
//      * <p>
//      * Returns the distance to the given {@link Box}. For a
//      * {@link Box} this might be Euclidean distance but for an EPSG4326
//      * lat-long Rectangle might be great-circle distance. The distance function
//      * should satisfy the following properties:
//      * </p>
//      * 
//      * <p>
//      * <code>distance(r) &gt;= 0</code>
//      * </p>
//      * 
//      * <p>
//      * <code>if r1 contains r2 then distance(r1)&lt;=distance(r2)</code>
//      * </p>
//      * 
//      * 
//      * @param r
//      *            rectangle to measure distance to
//      * @return distance to the rectangle r from the geometry
//      */
//     double distance(Box r);
// 
//     /**
//      * Returns the minimum bounding rectangle of this geometry.
//      * 
//      * @return minimum bounding rectangle
//      */
//     Box mbb();
// 
//     boolean intersects(Box r);
// }


// Path: src/main/java/com/github/davidmoten/rtree3d/Backpressure.java
import rx.Subscriber;
import rx.functions.Func1;
import com.github.davidmoten.rtree3d.geometry.Geometry;
import com.github.davidmoten.util.ImmutableStack;

package com.github.davidmoten.rtree3d;



/**
 * Utility methods for controlling backpressure of the tree search.
 */
final class Backpressure {

    private Backpressure() {
        // prevent instantiation
    }

    static <T, S extends Geometry> ImmutableStack<NodePosition<T, S>> search(