A modified DIviding RECTangles algorithm for a problem in astrophysics