private Node rebuild(Node left, Node right) {
        nums = new ArrayList<>();
        traverse(left);
        traverse(right);
        Node ptr = new Node(nums.get(0));
        for (int i = 1; i < nums.size(); ++i) {
            insert_helper(ptr, null, 0, nums.get(i));
        }
        return ptr;
    }