<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def add_membership(self, name_or_org, role='member', **kwargs):
 """ add a membership in an organization and return the membership object in case there are more details to add """

        if isinstance(name_or_org, Organization):
            membership = Membership(person_id=self._id,
                                    person_name=self.name,
                                    organization_id=name_or_org._id,
                                    role=role, **kwargs)
        else:
            membership = Membership(person_id=self._id,
                                    person_name=self.name,
                                    organization_id=_make_pseudo_id(name=name_or_org),
                                    role=role, **kwargs)
        self._related.append(membership)
        return membership