A Modified DIviding RECTangles Algorithm for a Problem in Astrophysics