filter tree grammar mode

I think what we really need is a filter mode for trees just like we have for lexer's. This would be almost a declarative approach where you say what trees you want to match and what actions to execute when you see it. For example,

tree grammar TP;

options {filter=true;}

IDENTITY
	:	^(MULT i:INT j:INT) {$i.text.equals("1")||$j.text.equals("1")}?
		-> i
	;

pretty sweet. of course I need tree grammars to be able to generate trees before I can do this.

The idea will be that it tries all patterns looking for a match in the order specified. An index can be used to speedthings up by only attempting rules on nodes in the tree that can possibly match. For example if there is only one MULT node in the entire tree, don't walk the entire tree looking for that pattern.