We present an algorithm for mining tree-shaped patterns in a large graph. Novel about our class of patterns is that they can contain constants, and can contain existential nodes which are not counted when determining the number of occurrences of the pattern in the graph. Our algorithm has a number of provable optimality properties, which are based on the theory of conjunctive database queries. We propose a database-oriented implementation in SQL, and report upon some initial experimental results obtained with our implementation on graph data about food webs, about protein interactions, and about citation analysis. Categories and Subject Descriptors H.2.8 [Database Management]: Database Applications-data mining General Terms Algorithms, Performance, Experimentation Keywords Canonical form, conjunctive query, equivalence checking, graph, levelwise, redundancy checking, SQL, tree query