The motivation for this paper is the study of the phase transition for recurrence/ transience of a class of self‐interacting random walks on trees, which includes the once‐reinforced random walk. For this purpose, we define a quantity, which we call the branching‐ruin number of a tree, which provides (in the spirit of Furstenberg [11] and Lyons [13]) a natural way to measure trees with polynomial growth. We prove that the branching‐ruin number of a tree is equal to the critical parameter for the recurrence/transience of the once‐reinforced random walk. We define a sharp and effective (i.e., computable) criterion characterizing the recurrence/transience of a larger class of self‐interacting walks on trees, providing the complete picture for their phase transition. © 2019 Wiley Periodicals, Inc.