public int removeAll(T data) {
        int removed = 0;
        Link<T> temp = head;

        while (temp != null) {
            if (temp.getData().equals(data)) {
                removed++;
                if (head == tail) {
                    head = null;
                    tail = null;
                } else {
                    if (temp.getPrev() != null) {
                        temp.getPrev().setNext(temp.getNext());
                    }
                    if (temp.getNext() != null) {
                        temp.getNext().setPrev(temp.getPrev());
                    }
                    if (temp == head) {
                        head = head.getNext();
                    }
                }
            }
            temp = temp.getNext();
        }
        length -= removed;
        return removed;
    }