Two new kinds of acyclic pushdown automata for trees in prefix notation are presented. First, \emph{subtree pushdown automata} accept all subtrees of the tree. Second, \emph{tree pattern pushdown automata} accept all tree patterns which match the tree. The presented pushdown automata are input--driven and therefore can be determinised. Given a tree with $n$ nodes, the deterministic subtree and the deterministic tree pattern pushdown automaton represent a complete index of the tree, and the search phase of all occurrences of a subtree or a tree pattern, respectively, of size $m$ is performed in time linear in $m$ and not depending on $n$. This is faster than the time of the existing tree pattern matching algorithms, which depends on $n$. The total size of the deterministic subtree pushdown automaton is linear in $n$. Although the number of distinct tree patterns which match the tree can be exponential in $n$, for specific cases of trees the total size of the deterministic tree pattern pushdown automaton is linear in $n$.