Include the contribution from Shyuep for python v3
An iterative approach is implemented for refine_cell