We are concerned with the numerical solution of a class of backward stochastic differential equations (BSDEs), where the terminal condition is a function of X-T, where X = {X-t, t is an element of [0, T]} is the solution to a standard stochastic differential equation (SDE). A characteristic of these type of BSDEs is that their solutions Y = {Y-t, t is an element of [0, T]} can be written as functions of time and X, Y-t = V-t(X-t). Moreover, the function V-t can be represented as the expected value of a functional of X. Therefore, since the forward component X-t is "known" at time t, the problem of estimating Y-t amounts to obtaining an approximation of the expected value of the corresponding functional. The approximation of the solution of a BSDE requires an approximation of the law of the solution of the SDE satisfied by the forward component. We introduce a new algorithm, combining the Euler style discretization for BSDEs and the cubature method of Lyons and Victoir [Proc. R. Soc. Lond. Ser. A Math. Phys. Eng. Sci., 460 (2004), pp. 169-198]. The latter is an approximation method for the law of the solution of an SDE that generates a tree on which expectations and conditional expectations are evaluated. To treat the exponential growth in the number of leaves on the tree, we appeal to the tree based branching algorithm introduced in [D. Crisan and T. Lyons, Monte Carlo Methods Appl., 8 (2002), pp. 343-355]. The convergence results are proved under very general assumptions. In particular, the vector fields defining the forward equation do not necessarily satisfy the Hormander condition. Numerical examples are also provided.