Index: src/org/openstreetmap/josm/data/coor/QuadTiling.java
===================================================================
--- src/org/openstreetmap/josm/data/coor/QuadTiling.java	(revision 6150)
+++ src/org/openstreetmap/josm/data/coor/QuadTiling.java	(working copy)
@@ -102,4 +102,11 @@
         int shift = NR_LEVELS-level-1;
         return (int)((x >> shift & 1) * 2 + (y >> shift & 1));
     }
+
+    /**
+     * Counts quad tiling index for given coordinates and level.
+     *
+     * @param lat latitude
+     * @param lon longitude
+     * @param level level
+     *
+     * @return quad tiling index for given coordinates and level.
+     */
+    static public int index(final double lat, final double lon, final int level) {
+        long x = lon2x(lon);
+        long y = lat2y(lat);
+        int shift = NR_LEVELS-level-1;
+        return (int)((x >> shift & 1) * 2 + (y >> shift & 1));
+    }
 }
Index: src/org/openstreetmap/josm/data/osm/BBox.java
===================================================================
--- src/org/openstreetmap/josm/data/osm/BBox.java	(revision 6150)
+++ src/org/openstreetmap/josm/data/osm/BBox.java	(working copy)
@@ -7,6 +7,7 @@
 
 import org.openstreetmap.josm.data.Bounds;
 import org.openstreetmap.josm.data.coor.LatLon;
+import org.openstreetmap.josm.data.coor.QuadTiling;
 import org.openstreetmap.josm.tools.Utils;
 
 public class BBox {
@@ -151,22 +152,6 @@
         return true;
     }
 
-    /**
-     * Returns a list of all 4 corners of the bbox rectangle.
-     */
-    public List<LatLon> points()  {
-        LatLon p1 = new LatLon(ymin, xmin);
-        LatLon p2 = new LatLon(ymin, xmax);
-        LatLon p3 = new LatLon(ymax, xmin);
-        LatLon p4 = new LatLon(ymax, xmax);
-        List<LatLon> ret = new ArrayList<LatLon>(4);
-        ret.add(p1);
-        ret.add(p2);
-        ret.add(p3);
-        ret.add(p4);
-        return ret;
-    }
-
     public LatLon getTopLeft() {
         return new LatLon(ymax, xmin);
     }
@@ -179,6 +164,25 @@
         return new LatLon(ymin + (ymax-ymin)/2.0, xmin + (xmax-xmin)/2.0);
     }
 
+    int getIndex(final int level) {
+
+        int idx1 = QuadTiling.index(ymin, xmin, level);
+
+        final int idx2 = QuadTiling.index(ymin, xmax, level);
+        if (idx1 == -1) idx1 = idx2;
+        else if (idx1 != idx2) return -1;
+
+        final int idx3 = QuadTiling.index(ymax, xmin, level);
+        if (idx1 == -1) idx1 = idx3;
+        else if (idx1 != idx3) return -1;
+
+        final int idx4 = QuadTiling.index(ymax, xmax, level);
+        if (idx1 == -1) idx1 = idx4;
+        else if (idx1 != idx4) return -1;
+
+        return idx1;
+    }
+
     @Override
     public int hashCode() {
         return (int)(ymin * xmin);
Index: src/org/openstreetmap/josm/data/osm/QuadBuckets.java
===================================================================
--- src/org/openstreetmap/josm/data/osm/QuadBuckets.java	(revision 6150)
+++ src/org/openstreetmap/josm/data/osm/QuadBuckets.java	(working copy)
@@ -158,7 +158,7 @@
             if (!hasChildren())
                 return this;
             else {
-                int index = get_index(bbox, level);
+                int index = bbox.getIndex(level);
                 if (index == -1)
                     return this;
                 return getChild(index).findBucket(bbox);
@@ -183,31 +183,7 @@
             }
             return ret;
         }
-        // Get the correct index for the given primitive
-        // at the given level.  If the primitive can not
-        // fit into a single quad at this level, return -1
-        int get_index(BBox bbox, int level) {
-            int index = -1;
-            for (LatLon c : bbox.points()) {
-                /*if (debug) {
-                    out("getting index for point: " + c);
-                }*/
-                if (index == -1) {
-                    index = QuadTiling.index(c, level);
-                    /*if (debug) {
-                        out("set initial index to: " + index);
-                    }*/
-                    continue;
-                }
-                int another_index = QuadTiling.index(c, level);
-                /*if (debug) {
-                    out("other point index: " + another_index);
-                }*/
-                if (another_index != index)
-                    return -1;
-            }
-            return index;
-        }
+
         /*
          * There is a race between this and qb.nextContentNode().
          * If nextContentNode() runs into this bucket, it may
@@ -224,7 +200,7 @@
             content = null;
 
             for (T o: tmpcontent) {
-                int index = get_index(o.getBBox(), level);
+                int index = o.getBBox().getIndex(level);
                 if (index == -1) {
                     __add_content(o);
                 } else {
@@ -377,8 +353,8 @@
                 if (!matches(o, this.bbox())) {
                     /*out("-----------------------------");
                     debug = true;*/
-                    get_index(o.getBBox(), level);
-                    get_index(o.getBBox(), level-1);
+                    o.getBBox().getIndex(level);
+                    o.getBBox().getIndex(level-1);
                     int nr = 0;
                     /*for (QBLevel sibling : parent.getChildren()) {
                         out("sibling["+ (nr++) +"]: " + sibling.bbox() + " this: " + (this==sibling));
