Simpler:

    depth = depth >= depth.max / 2 ? (depth / 3) * 2 : (depth * 2) / 3;

The impact is very likely to be immeasurable because the actual work involved is a lot more than the branch itself. @Geod24 please make this change and let's get this in. Thanks!