     final class Node {
         let value: V
         var next: Node?
-        weak var previous: Node?
+        var previous: Node?
 
         init(value: V) { self.value = value }
     }

    }

    func removeAll() {
        // Here's a clever trick to avoid recursive Nodes deallocation
        var node = tail
        while let previous = node?.previous {
            previous.next = nil
            node = previous
        }

        head = nil
        tail = nil
    }


// MARK: - LinkedList

// Basic doubly linked list.
internal final class LinkedList<V> {
    // head <-> node <-> ... <-> tail
    private(set) var head: Node?
