def __iter__(self): """Supports a pre_order traversal on a view of self.""" if not self.is_empty(): stack = LinkedStack() stack.push(self._root) while not stack.is_empty(): node = stack.pop() yield node.data if node.right is not None: stack.push(node.right) if node.left is not None: stack.push(node.left)