Given a Lipschitz map 𝑓 from a cube into a metric space, we find several equivalent conditions for 𝑓 to have a Lipschitz factorization through a metric tree. As an application, we prove a recent conjecture of David and Schul. The techniques developed for the proof of the factorization result yield several other new and seemingly unrelated results. We prove that if 𝑓 is a Lipschitz mapping from an open set in ℝ 𝑛 onto a metric space 𝑋, then the topological dimension of 𝑋 equals 𝑛 if and only if 𝑋 has positive 𝑛-dimensional Hausdorff measure. We also prove an area formula for length-preserving maps between metric spaces, which gives, in particular, a new formula for integration on countably rectifiable sets in the Heisenberg group.