First of all, the property of a transaction being a tip is volatile and can change before the walk even finishes. So even if the function was guaranteed to find a tip, by the time it returned it could already be a non-tip (as somebody else approved it). Also keep in mind that the property of a transaction being a tip is not the same in the whole network, a tip on your node may already be approved multiple times on another node.
That being said, the conditions that you found are there to prevent choosing a transaction that it could not verify - for example a non-solid one, which is a transaction where its second approved transaction is not yet present on your node, or a transaction that approves two conflicting transactions. In those cases it is better to stop before that transaction and approve this other transaction, which technically is no longer a tip but better to choose that non-tip than throwing away all the random walk so far.
Another point to keep in mind: Users/Nodes on the IOTA network may be hostile and deliberately introduce transactions that approve double spends or approve non-existing transactions. Usually the best way to take care of these users is ignoring that they are there, i. e. stop the walks before their invalid transactions and approve the previous transactions even if they are no longer tips.