You mean if the list is undsorted it might return random indexes? But that won't be the case here since the list is sorted bottoms up.
Anyway, the problem with my code was that I had "obj.getDepth()" as the key-parameter in the binarySearch method when "obj" was correct.
The binarySearch returns the index in the list where the object fits in, and if it doesn't fit anywhere, it returns a negative value of what index it would have taken if it could have. So that's easy enough to convert back to its positive value.
Now it works fine as far as I can see:)
Thanks for your help,
jon
[EDIT] Here's a quick before and after glance for those interested
