'Increases the size of the cache by inserting n empty nodes at the tail of the list'

def expand(self, n):

    n = max(0, n)
    left = n
    while (left > 0):
        left -= 1
        node = DoublyLinkedNode()
        node.next = self.head
        node.prev = self.head.prev
        self.head.prev.next = node
        self.head.prev = node
    self._size += n
