def METHOD_NAME(self, compartments):
    query_compartment_ids = [id for id in compartments]
    for id in compartments:
        children = [c['id'] for c in self.all_compartments if c['compartment_id'] == id]
        query_compartment_ids.extend(self.METHOD_NAME(children))
    return query_compartment_ids