<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def trim(self):
 """ Trim leading and trailing whitespace. @return: self @rtype: L{Element} """

        if self.hasText():
            self.text = self.text.trim()
        return self