# How to surround portions of a tree with boxes

I need to group portions of a tree with boxes, and additionally label them, e.g. put "W1" on the side of the box, or in the top right corner of the box.

The result I want to achieve is somewhat similar to the one in the following video: http://youtu.be/B78RnoBFYOw?t=10m40s

or to this picture:

Note that the boxed subtrees must still refer to a node in the parent boxed subree. That is, I don't want a tree of boxes with trees inside, rather I want a single tree with boxes around some portions of it.

### Edit:

Here is the code I use so far to create the tree

\begin{tikzpicture}
\node{
$\forall{x}. P(x) \rightarrow Q(X)$\\
$P(x) \rightarrow Q(x)$
}
child{ node{$\lnot P(a)$} }
child{ node{$Q(a)$}
child{ node{other..} }
};
\end{tikzpicture}


By the way, what would be the best way to add multiple lines of math into a tree node? Right now, they are all on the same line.

-
How do you create your trees? Can you show us your code? For TikZ-based solution the fit library will help. –  Qrrbrbirlbel May 19 at 15:51
I've tried to use the qtree, embedded into fancybox (ovalbox), but it isn't working for me right now... I think TikZ could definitely come to the rescue –  decden May 19 at 16:00