         let lineBoundingBox = line.boundingBox
         var results: [IndexedPathComponentLocation] = []
         self.bvh.visit { (node: BVHNode, depth: Int) in
-            if case let .leaf(object, elementIndex) = node.nodeType {
-                let curve = object as! BezierCurve
+            if case let .leaf(elementIndex) = node.nodeType {
+                let curve = self.curves[elementIndex]
                 results += curve.intersects(line: line).compactMap {
-                return IndexedPathComponentLocation(elementIndex: elementIndex, t: $0.t1)
+                    return IndexedPathComponentLocation(elementIndex: elementIndex, t: $0.t1)
                 }
             }
             // TODO: better line box intersection

            if boundingBox.upperBoundOfDistance(to: p) <= d {
                found = true
            }
            else if case let .leaf(object, _) = node.nodeType {
                let curve = object as! BezierCurve
                if distance(p, curve.project(point: p)) < d {
                    found = true
                }

    public func intersects(component other: PathComponent, threshold: CGFloat = BezierKit.defaultIntersectionThreshold) -> [PathComponentIntersection] {
        precondition(other !== self, "use intersects(threshold:) for self intersection testing.")
        var intersections: [PathComponentIntersection] = []
        self.bvh.intersects(node: other.bvh) { i1, i2 in
            let c1 = self.curves[i1]
            let c2 = other.curves[i2]
            let elementIntersections = c1.intersects(curve: c2, threshold: threshold)
            let pathComponentIntersections = elementIntersections.compactMap { (i: Intersection) -> PathComponentIntersection? in
                let i1 = IndexedPathComponentLocation(elementIndex: i1, t: i.t1)
