Quasi-actions on trees I. Bounded valence