This function used to call itself recursively to traverse the linked list, which seemed odd. Now we just iterate over the array.