@Override
    public Iterator<E> iterator() {
        return new Iterator<E>() {
            private int current = size - 1;
            private Node<E> tempLast = last;

            @Override
            public boolean hasNext() {
                return current >= 0;
            }

            @Override
            public E next() {
                if (!hasNext()) {
                    return null;
                }
                E result = tempLast.getElement();
                tempLast = tempLast.getPrevious();
                if (tempLast != null)
                    tempLast.setNext(null);
                current--;
                return result;
            }

            @Override
            public void remove() {
                if (hasNext()) {
                    pop();
                    current--;
                }
            }
        };
    }