<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def traverse_parents(self, visit, *args, **kwargs):
 """ Traverse the hierarchy upwards, visiting all parents and their children except self. See "visitor pattern" in literature. This is implemented in pre-order fashion. Example: parents = [] self.traverse_parents(parents.append) print parents """

        if self.has_parent():
            self.__visited = True
            self._parent_.traverse_parents(visit, *args, **kwargs)
            self._parent_.traverse(visit, *args, **kwargs)
            self.__visited = False