code: public void endInterval(int lastIndex) {
          if (isOpen) {
              currentDetail.setLast(lastIndex);
              pathDetails.add(currentDetail);
          }
          isOpen = false;
      }
docs: Ending intervals multiple times is safe, we only write the interval if it was open and not empty.
  Writes the interval to the pathDetails
  
  @param lastIndex the index the PathDetail ends