@Override
    public Iterator<T> iterator()
    {
        return new Iterator<T>()
        {

            private Node<T> current  = head;
            private Node<T> prev = null;

            @Override
            public boolean hasNext()
            {
                return current != null;
            }

            @Override
            public T next()
            {
                prev = current;
                if (current != null) {
                    current = current.getNext();
                }
                if (prev != null) {
                    return prev.getData();
                }
                else {
                    return null;
                }
            }

            // Returns the element that was last returned by next()
            @Override
            public void remove()
            {
                if (prev == null) {
                    // next hasn't been called, or the list is empty. Nothing to
                    // remove.
                    return;
                }
                if (prev.getNext() != null) {
                    prev.getNext().setPrev(prev.getPrev());
                }
                if (prev.getPrev() != null) {
                    prev.getPrev().setNext(prev.getNext());
                }
                if (head == prev) {
                    head = prev.getNext();
                }
                if (tail == prev) {
                    tail = prev.getPrev();
                }
                prev = prev.getPrev();
                len--;
            }
        };
    }