<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def findOne(self, query=None, mode=FindOneMode.FIRST, **kwargs):
 """ Perform a find, with the same options present, but only return a maximum of one result. If find returns an empty array, then None is returned. If there are multiple results from find, the one returned depends on the mode parameter. If mode is FindOneMode.FIRST, then the first result is returned. If the mode is FindOneMode.LAST, then the last is returned. If the mode is FindOneMode.ERROR, then a SlickCommunicationError is raised. """

        results = self.find(query, **kwargs)
        if len(results) is 0:
            return None
        elif len(results) is 1 or mode == FindOneMode.FIRST:
            return results[0]
        elif mode == FindOneMode.LAST:
            return results[-1]