Fix incorrect iteration in db_services_leaf