<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def depthfirstsearch(self, function):
 """Generic depth first search algorithm using a callback function, continues as long as the callback function returns None"""

        result = function(self)
        if result is not None:
            return result
        for e in self:
            result = e.depthfirstsearch(function)
            if result is not None:
                return result
        return None