We present a careful approximation of the quasi-geodesics of trees of hyperbolic and relatively hyperbolic spaces. As an application we prove a dynamical and geometric combination theorem for trees of relatively hyperbolic spaces, with both Farb's and Gromov's definitions.