I hope it helps, as it is only an educated guess that ptr_first DOES differentiate.
It my conclusion it will because your flow is like so...
A> ptr_first is retrieves the first object of a given type.
B> then you step through using ent.link.next
Now, seeing as the "link" data in any object is primarily its handle,
then anything else in the link data will "most likely" recognise the same types.
So ... if you are stepping through the "handles", and the handle function sees a
difference between the three entity types, then ptr_first PROBABLY does too.
That the logic I followed anyways...