<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def user_sentiments_most_frequent( self, username = None, single_most_frequent = True ):
 """ This function returns the most frequent calculated sentiments expressed in tweets of a specified user. By default, the single most frequent sentiment is returned. All sentiments with their corresponding frequencies can be returned also. """

        try:
            sentiment_frequencies = collections.Counter(self.user_sentiments(
                username = username
            ))
            if single_most_frequent:
                return sentiment_frequencies.most_common(1)[0][0]
            else:
                return dict(sentiment_frequencies)
        except:
            log.error("error -- possibly no username specified")
            return None