private static <T> BinaryTree<T> reconstruct_post_in_orders_helper(ArrayList<T> post, int post_s, int post_e,
                                                                       ArrayList<T> in, int in_s, int in_e) {
        if(post_e > post_s && in_e > in_s) {
            int it = in.subList(in_s, in_e).indexOf(post.get(post_e - 1));
            it = it < 0 ? in_e : (it + in_s);
            int left_tree_size = it - in_s;
            return new BinaryTree<T>(post.get(post_e - 1),
                    // Recursively build the left subtree.
                    reconstruct_post_in_orders_helper(
                            post, post_s, post_s + left_tree_size,
                            in, in_s, it),
                    // Recursively build the right subtree.
                    reconstruct_post_in_orders_helper(
                            post, post_s + left_tree_size, post_e - 1,
                            in, it + 1, in_e));
        }
        return null;
    }