Did your comment get chopped off?

A quick example. Imagine these index contents (e.g. UNIQUE INDEX(child.parent_id)):
(10, 1)
(20, 2)
(30, 3)

Assume the incoming key is primed with (10), the code as is will next(true) to (10,1), next(true) to (20, 2) and return true for the last hasNext -- which is wrong. We really just need to check if there are multiple siblings of (10, x).

But, the bigger point is there I don't think this code path ever gets hit. The *referencing* (child) side index is never unique and getDepth() is only < size() for a unique index.