If the condition in line 14 evaluates to true, then lines 15 through 20 are executed, which inserts the data into the list and coincidentally sets head to a non-null value.
This being the case, when line 22 is encountered, the condition in the if there will also evaluate to true, and lines 23 through 28 will be executed, inserting the data into the list again.