<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def existing_social_friends(self, user_social_auth=None, friend_ids=None):
 """ fetches and matches social friends if friend_ids is None, then fetches them from social network Return: User collection """

        # Type check
        self.assert_user_is_social_auth_user(user_social_auth)

        if not friend_ids:
            friend_ids = self.fetch_social_friend_ids(user_social_auth)

        # Convert comma sepearated string to the list
        if isinstance(friend_ids, basestring):
            friend_ids = eval(friend_ids)

        # Match them with the ones on the website
        if USING_ALLAUTH:
            return User.objects.filter(socialaccount__uid__in=friend_ids).all()            
        else:
            return User.objects.filter(social_auth__uid__in=friend_ids).all()