Improve the function calc_D() which computes the distance between quadrats that have been bisected by a given separation order.