  In this paper, we address the following question: when is a finite $p$-group
$G$ self-similar, i.e. when can $G$ be faithfully represented as a self-similar
group of automorphisms of the $p$-adic tree? We show that, if $G$ is a
self-similar finite $p$-group of rank $r$, then its order is bounded by a
function of $p$ and $r$. This applies in particular to finite $p$-groups of a
given coclass. In the particular case of groups of maximal class, that is, of
coclass $1$, we can fully answer the question above: a $p$-group of maximal
class $G$ is self-similar if and only if it contains an elementary abelian
maximal subgroup over which $G$ splits. Furthermore, in that case the order of
$G$ is at most $p^p+1$, and this bound is sharp.

Group Theory