  We derive the exact partition function for a discrete model of random trees
embedded in a one-dimensional space. These trees have vertices labeled by
integers representing their position in the target space, with the SOS
constraint that adjacent vertices have labels differing by +1 or -1. A
non-trivial partition function is obtained whenever the target space is bounded
by walls. We concentrate on the two cases where the target space is (i) the
half-line bounded by a wall at the origin or (ii) a segment bounded by two
walls at a finite distance. The general solution has a soliton-like structure
involving elliptic functions. We derive the corresponding continuum scaling
limit which takes the remarkable form of the Weierstrass p-function with
constrained periods. These results are used to analyze the probability for an
evolving population spreading in one dimension to attain the boundary of a
given domain with the geometry of the target (i) or (ii). They also translate,
via suitable bijections, into generating functions for bounded planar graphs.
