Recursive algorithm that counts the number of nodes in a singly linked list