def get_all_children(self, include_self=False):
        """
        Return all subsidiaries of this company.
        """
        ownership = Ownership.objects.filter(parent=self)
        subsidiaries = Company.objects.filter(child__in=ownership)
        for sub in subsidiaries:
            subsidiaries = subsidiaries | sub.get_all_children()

        if include_self is True:
            self_company = Company.objects.filter(id=self.id)
            subsidiaries = subsidiaries | self_company

        return subsidiaries
def get_all_children ( self , include_self = False ) : ownership = Ownership . objects . filter ( parent = self ) subsidiaries = Company . objects . filter ( child__in = ownership ) for sub in subsidiaries : subsidiaries = subsidiaries | sub . get_all_children ( ) if include_self is True : self_company = Company . objects . filter ( id = self . id ) subsidiaries = subsidiaries | self_company return subsidiaries
Return all subsidiaries of this company.