This is code dependant issue, ie it depends on the way u wrote the code & defined the data structure in it.
If u r following the Wikipedia code ( took it from there). I didn't read the whole code but according to the fig they're attaching
-A leaf node has children links = Null (or nil depending on the programming language u r using)
-Also, the internal nodes linked list link ( the red square in the Fig) should equal Null as opposed to leaf nodes.
-Since this is only 1 pointer, ie easier to check, u could write something like
While (node.linked_list != Null)
To stop the loop when u reach a leaf
(Note that a storage saving code would use one of the children links, say the 1st, as the linked list link, substituting the need to another pointer field by 1-bit Boolean flag identifying leaf nodes and consequently the meaning of this pointer)
That's a 2 yrs old question, probably the student graduated & already became a developer by now!!!!