public void insert(Road r) {
        if (nodes[0] != null) {
            int index = getIndex(roadToRect(r));

            if (index != -1) {
                nodes[index].insert(r);

                return;
            }
        }

        objects.add(r);

        if (objects.size() > MAX_OBJECTS && level < MAX_LEVELS) {
            if (nodes[0] == null) {
                split();

                int i = 0;
                while (i < objects.size()) {
                    int index = getIndex(roadToRect(objects.get(i)));
                    if (index != -1) {
                        nodes[index].insert(objects.get(i));
                        objects.remove(i);
                    } else {
                        i++;
                    }
                }
            }
        }
    }