<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_fieldsets(self, request, obj=None):
 """ Add ownership info fields in fieldset with proper separation. Author: Himanshu Shankar (https://himanshus.com) """

        fieldsets = list(super(CreateUpdateAdmin, self).get_fieldsets(
            request=request, obj=obj))

        # Create sets for future use
        fields = set()
        to_add = set()

        # Prepare a set of existing fields in fieldset
        for fs in fieldsets:
            fields = fields.union(fs[1]['fields'])

        # Loop over ownership info fields
        for k, v in self.ownership_info['fields'].items():

            # Check if current model has k attribute
            # and field k is not already in fieldset
            # and field k has not been excluded
            if (hasattr(self.model, k)
                    and k not in fields
                    and (not self.exclude
                         or (self.exclude and k not in self.exclude))):

                # Now, let's hide fields in add form, it will be empty
                # Check if readonly property is not True
                # or this is an edit form
                if ('readonly' in v and not v['readonly']) or obj:
                    to_add.add(k)

        # If to_add set is not empty, add ownership info to fieldset
        if len(to_add) > 0:
            fieldsets.append((self.ownership_info['label'],
                              {'fields': tuple(to_add)}))
        return tuple(fieldsets)