code: List<BTreePage> splitIfNecessary() {
          if (this.contents.getLength() <= this.config.getMaxPageSize()) {
              // Nothing to do.
              return null;
          }
  
          // Calculate how many pages to split into. While doing so, take care to account that we may only have whole entries
          // in each page, and not partial ones.
          int maxDataLength = (this.config.getMaxPageSize() - this.header.getLength() - this.footer.getLength()) / this.config.entryLength * this.config.entryLength;
          int remainingPageCount = (int) Math.ceil((double) this.data.getLength() / maxDataLength);
  
          ArrayList<BTreePage> result = new ArrayList<>(remainingPageCount);
          int readIndex = 0;
          int remainingItems = getCount();
          while (remainingPageCount > 0) {
              // Calculate how many items to include in this split page. This is the average of the remaining items over
              // the remaining page count (this helps smooth out cases when the original getCount() is not divisible by
              // the calculated number of splits).
              int itemsPerPage = remainingItems / remainingPageCount;
  
              // Copy data over to the new page.
              ByteArraySegment splitPageData = this.data.subSegment(readIndex, itemsPerPage * this.config.entryLength);
              result.add(new BTreePage(this.config, itemsPerPage, splitPageData));
  
              // Update pointers.
              readIndex += splitPageData.getLength();
              remainingPageCount--;
              remainingItems -= itemsPerPage;
          }
  
          assert readIndex == this.data.getLength() : "did not copy everything";
          return result;
      }
docs: If necessary, splits the contents of this BTreePage instance into multiple BTreePages. This instance will not be
  modified as a result of this operation (all new BTreePages will be copies).
  
  The resulting pages will be about half full each, and when combined in order, they will contain the same elements
  as this BTreePage, in the same order.
  
  Split Conditions:
  * Length > MaxPageSize
  
  @return If a split is made, an ordered List of BTreePage instances. If no split is necessary (condition is not met),
  returns null.