  A 1970 article of J. Tits concerning groups acting on trees introduced an
independence property $(\mathrm{P})$ as a condition to produce the first
examples of nonlinear nondiscrete locally compact simple groups, answering a
question of J. P. Serre. This property has become very important in the recent
development of the theory of totally disconnected, locally compact (t.d.l.c.)
groups, with the majority of new constructions of compactly generated simple
t.d.l.c. groups using $(\mathrm{P})$ or related ideas.
  In this paper we aim to advance the local-to-global theory of groups acting
on trees by developing a `local action' complement to classical Bass--Serre
theory. We describe, for a closed group $G$ of automorphisms of a (not
necessarily locally finite) tree $T$ something called a local action diagram: a
graph decorated with the local actions of $G$. A local action diagram plays a
role in our theory that is analogous to a graph of groups in Bass--Serre
theory. In place of the universal cover of a graph of groups, we define the
universal group of a local action diagram. In this context, the groups
$\mathbf{U}(F)$ and $\mathbf{U}(F_1, F_2)$ play analogous roles to the HNN
extension and amalgamated free product respectively in Bass--Serre theory. We
then show how to determine whether the universal group has certain properties,
such as geometric density, compact generation and simplicity, directly from the
local action diagram.
  Our theory allows us to completely describe all closed groups of
automorphisms of trees with Tits' independence property $(\mathrm{P})$: they
are precisely the universal groups of local action diagrams.
