docs: function calculateExpansions() {
      let impl = function(expansions, parentStart, parentLevel) {
          expansions.forEach((expansion, index) => {
              expansion._level = parentLevel;
  
              // We need to calculate the start position of this expansion. The start
              // position isn't just the offset of the item relative to the parent, but
              // also takes into account expanded items above it. 
              //
              // One easy way to do this is to just check the previous item and get its end index.
              // We fetch the one on the same level not above or below. That should in theory
              // already have a start/end relative to the parent. If there isn't a previous sibling
              // then we will take the parent start value. Add onto this the offset for the item
              // and we've got our starting value.
              //
              // eg. 
              //   Item 1 <-- start 0, end 0
              //   Item 2 <-- start 2, end 8
              //       Item 2.1 <-- start 3, end 3
              //          Item 2.1.1
              //       Item 2.2
              //       Item 2.3 <-- start 6, end 6
              //          Item 2.3.1
              //       Item 2.4 <-- start 8, end 8
              //          Item 2.4.1 
              //   Item 3
              //   Item 4 <-- start 11, end 12
              //       Item 4.1
              //       Item 4.2
              let start, end;
              let prevSibling = expansions[index - 1];
              if (prevSibling) {
                  start = prevSibling._end + 1 + (expansion.offset - prevSibling.offset);
              } else {
                  start = parentStart + 1 + expansion.offset;
              }
  
              expansion._start = start;
  
              // To calculate the ending, we recursively add the children
              // for this expansion, and that will be added to the start value.
              let totalChildren = expansion.children;
              forEachExpansion(expansion.expansions, (expansion) => {
                  totalChildren += expansion.children;
              });
  
              // We add the children and substract one. We subtract one because
              // the start is one of the children.
              expansion._end = expansion._start + totalChildren - 1;
  
              // Repeat this recursively for all of the nested expansions.
              // The nested expansions will have a relative start to this 
              // expansion.
              impl(expansion.expansions, expansion._start, parentLevel + 1);
          });
      }
  
      impl(_(this).expansions, -1, 0);
  }