A minor comment, but if you set bestQuality to MIN_VALUE 6 lines above here you wouldn't need best==null (nor would you need to set best to null above), which saves you quite a few comparisons in the long run. Unless the possibility of .getFit() equalling MIN_VALUE is a real concern. If it is, before the while loop best could be set to the first entry of childArr.