         nodes = duplicatesRemoved
     }
     func createComponent(from startingNode: Node) -> PathComponent {
-        let firstPoint = startingNode.edge!.component.startingPoint
+        let firstPoint = startingNode.component.startingPoint
         var points: [CGPoint] = [firstPoint]
         var orders: [Int] = []
         func visit(from node: Node) -> Node? {
-            guard let forwardEdge = node.edge else {
-                assertionFailure("consistency failure")
-                return nil
-            }
-            guard let backwardsEdge = node.previous?.edge else {
-                assertionFailure("consistency failure")
-                return nil
-            }
-            if forwardEdge.inSolution, forwardEdge.visited == false {
-                visit(forwardEdge.component)
-                forwardEdge.visited = true
-                return node.next
-            } else if backwardsEdge.inSolution, backwardsEdge.visited == false {
-                visit(backwardsEdge.component.reversed())
-                backwardsEdge.visited = true
-                return node.previous
-            } else {
-                return nil
-            }
+            if let next = node.next {
+                let forwardEdge = node.edge
+                if forwardEdge.inSolution, forwardEdge.visited == false {
+                    visit(node.component)
+                    forwardEdge.visited = true
+                    return next
+                }
+            } else {
+                assert(node.component.isClosed == false, "expected next node to exist")
+            }
+            if let previous = node.previous {
+                let backwardsEdge = previous.edge
+                if backwardsEdge.inSolution, backwardsEdge.visited == false {
+                    visit(node.backComponent)
+                    backwardsEdge.visited = true
+                    return previous
+                }
+            } else {
+                assert(node.component.isClosed == false, "expected previous node to exist")
+            }
+            return nil
         }
         func visit(_ component: PathComponent) {
             points += component.points[1..<component.points.count]

}

private extension AugmentedGraph {
    func pointIsContainedInBooleanResult(point: CGPoint, operation: BooleanPathOperation) -> Bool {
        let rule: PathFillRule = (operation == .removeCrossings) ? .winding : .evenOdd
        let contained1 = self.path1.contains(point, using: rule)
        let contained2 = operation != .removeCrossings ? self.path2.contains(point, using: rule) : contained1
        switch operation {
        case .union:
            return contained1 || contained2

            return contained1
        }
    }
    static func sortAndMergeDuplicates(of nodes: inout [Node]) {
        guard nodes.count > 1 else { return }
        nodes.sort(by: { $0.location < $1.location })
