  Given a graph $G=(V, E)$, its generalized Laplacian matrix is given by \[
L(G,X_G)_{u,v}= \begin{cases} x_u&\text{if }u=v,\\ -m_{uv}&\text{if }u\neq v,
\end{cases} \] where $X_G=\{x_u\, | \, u\in V(G)\}$ is a set of indeterminates
and $m_{uv}$ is the number of edges between $u$ and $v$. The $j$-critical ideal
of $G$ is the determinantal ideal generated by the minors of size $j$ of $L(G,
X)$. A $2$-matching of $G$ is a subset $\mathcal{M}$ of its edges such that
every vertex of $G$ has at most two incident edges in $\mathcal{M}$. We give a
combinatorial description of a set of generators of the $j$-critical ideal of a
tree $T$ as a function of a set of special $2$-matchings, which we called
minimal, of the graph $T^\ell$ obtained from $T$ by adding a loop at each of
its vertices. Also, we prove that the algebraic co-rank of $T$ is equal to the
$2$-matching number of $T$, the maximum number of edges of a $2$-matching of
$T$. As a consequence, one can compute each invariant factor of the critical
group of any graph $G$ such that $G\setminus v$ is a tree for some of its
vertices $v$, as the greatest common divisor of the evaluation of some
polynomials associated to the minimal $2$-matchings of $T^\ell$. For instance,
in the regular case, we recover some of the results obtained by Levine and
Toumpakari about the critical group of a wired regular tree. Additionally, we
can prove that the path $P_n$ is the unique simple graph with $n$ vertices and
$n-1$ trivial critical ideals. We conjecture that the set of generators that we
give is a reduced Gr\"obner basis and we can prove this for the
$|V(T)|-1$-critical ideal. Finally, we apply the result in order to calculate
the critical ideals of trees with depth two and some arithmetical trees
associated to the reduction of elliptic curves of Kodaira type $I_n^*$.
