int findBeginIndex(Node n, double key, boolean inclusive) {
      boolean exclusive = !inclusive;
      if (key <= n.first()) {
        if (key == n.first() && exclusive) return 1;
        return 0;
      }
      int pos = n.findKeyIndex(key);
      if (pos < 0) pos = -(pos + 1);
      else if (!inclusive) pos++;

      return pos;
    }
    int findEndIndex(Node n, double key, boolean inclusive) {
      boolean exclusive = !inclusive;
      if (key < n.first()) return -1;
      if (key >= n.last()) {
        if (key == n.last() && exclusive) return n.len() - 2;
        return n.len() - 1;
      }
      int pos = n.findKeyIndex(key);
      if (pos < 0) pos = -(pos + 1);
      else if (!inclusive) pos--;

      if (pos == n.len()) pos--;
      return pos;
    }