A lot of recent applications dealing with complex data require sophisticated data structures (trees or graphs) for their specification. Recently, several techniques for tree and graph mining have been proposed in the literature. In this paper, we focus on constraint-based tree mining. We propose to use tree automata as a mechanism to specify user constraints over tree patterns. We present the algorithm CobMiner which allows user constraints specified by a tree automata to be incorporated in the mining process. An extensive set of experiments executed over synthetic and real data allow us to conclude that incorporating constraints during the mining process is far better effective than filtering the frequent and interesting patterns after the mining process.