public ArrayList<Occurrence> toArray() {
        ArrayList<Occurrence> array = new ArrayList<Occurrence>();
        Occurrence temp = head;
        while (head != null) {
            array.add(head);
            head = head.next;
        }
        head = temp;
        return array;
    }