I wanted the function to be void because my "addNode" function already returns a pointer and I wanted to practice both ways.
But I didn't fully think this through. The options you listed made me understand the concept a lot better.
The while loop was just the first thing that came to my mind, but what you wrote makes sense of course.
Also I already knew that the behavior of my function was inconsistent, but didn't fix it before posting here.

Thank you very much for your help!