class DoublyLinkedList implements Iterable<T> {

    public void remove(ListNode2<T> node)
    {
        if (node == tail)
        {
            tail = node.next;
        }
        else
        {
            node.prev.next = node.next;
        }

        if (node == head)
        {
            head = node.prev;
        }
        else
        {
            node.next.prev = node.prev;
        }
        size--;
    }

}