quad tree recursive ruby solve