Is there any good advice on how to improve performance in terms of algorithm time complexity? I am using a recursive solution and am not sure if any faster non-recursive solution exists.import sysclass TreeNode:    def __init__(self, value, left, right):        self.value = value        self.left = left        self.right = right    def serialize_tree(self, result):        result.append(self.value)        if self.left:            self.left.serialize_tree(result)        if self.right:            self.right.serialize_tree(result)    def print_tree(self, result):        result.append(self.value)        if self.left:            self.left.print_tree(result)        else:            result.append('#')        if self.right:            self.right.print_tree(result)        else:            result.append('#')    @staticmethod    def deserialize_tree(source):        if len(source) == 1:            return TreeNode(source[0], None, None)        cur = TreeNode(source[0], None, None)        for i,v in enumerate(source):            if i == 0:                root_value = v                continue            if v > root_value:                break        if v > root_value:            cur.right = TreeNode.deserialize_tree(source[i:])        if v > root_value and i - 1 > 0:            cur.left = TreeNode.deserialize_tree(source[1:i])        if not (v > root_value) and i == len(source) - 1:            cur.left = TreeNode.deserialize_tree(source[1:i+1])        return curif __name__ == __main__:    #   5    #  3 6    # 2   7    root = TreeNode(5, TreeNode(3, TreeNode(2, None, None), None), TreeNode(6, None, TreeNode(7, None, None)))    result = []    root.serialize_tree(result)    print result    new_root = TreeNode.deserialize_tree(result)    result2 = []    new_root.print_tree(result2)    print result2
Serialize and deserialize binary search tree
python;algorithm;python 2.7