code: function(segment, previousSegment, nextSegment) {
  
              // insert after previous segment and before previous segment's next segment
              segment.previousSegment = previousSegment;
              segment.nextSegment = nextSegment;
              if (previousSegment) previousSegment.nextSegment = segment;
              if (nextSegment) nextSegment.previousSegment = segment;
  
              var updateSubpathStart = segment;
              if (segment.isSubpathStart) {
                  segment.subpathStartSegment = segment; // assign self as subpath start segment
                  updateSubpathStart = nextSegment; // start updating from next segment
              }
  
              // assign previous segment's subpath start (or self if it is a subpath start) to subsequent segments
              if (updateSubpathStart) this.updateSubpathStartSegment(updateSubpathStart);
  
              return segment;
          }
docs: Helper method for adding segments.