  Self-similar group actions may be encoded by a class of left cancellative
monoids called left Rees monoids, a result obtained by combining pioneering
work by Perrot with later work by the first author. Left Rees monoids that are
also right cancellative are called Rees monoids. Irreducible Rees monoids have
the striking property that they are embedded in their universal groups and
these universal groups are HNN extensions by a single stable letter. In this
paper, we generalize the above theory from monoids to categories. We study the
structure of left Rees categories and prove that Rees categories embed into
their universal groups. Furthermore, we show that from each graph of groups, we
may construct a Rees category and prove that the fundamental group of the
former is the universal group of the latter. In this way, Bass-Serre theory may
be viewed as a special case of the general problem of embedding categories into
groupoids.
