code: function() {
  
              var segments = this.segments;
              var numSegments = segments.length;
              if (numSegments === 0) return null; // if segments is an empty array
  
              var bbox;
              for (var i = 0; i < numSegments; i++) {
  
                  var segment = segments[i];
                  if (segment.isVisible) {
                      var segmentBBox = segment.bbox();
                      bbox = bbox ? bbox.union(segmentBBox) : segmentBBox;
                  }
              }
  
              if (bbox) return bbox;
  
              // if the path has only invisible elements, return end point of last segment
              var lastSegment = segments[numSegments - 1];
              return new Rect(lastSegment.end.x, lastSegment.end.y, 0, 0);
          }
docs: Returns the bbox of the path. If path has no segments, returns null. If path has only invisible segments, returns bbox of the end point of last segment.