public boolean insert(BranchSegment b) {
        if (!area.containsPoint(b.getPosition()))
            return false;

        if (size < MAX) {
            branches[size] = b;
            size++;
            return true;
        } else {
            for (int i = 0; i < size; i++) {
                BranchSegment existing = branches[i];
                if (existing.equals(b))
                    return true;
            }
        }

        if (!isSubdivided())
            subdivide();

        if (nw.insert(b))
            return true;
        if (ne.insert(b))
            return true;
        if (sw.insert(b))
            return true;
        if (se.insert(b))
            return true;

        throw new IllegalStateException("Something odd happened when inserting " + b
                + ". " + this + " " + nw + " " + ne + " " + sw + " " + se);
    }