Added function to apply rule to all nodes in tree, with a simple select rule. Also fixed a small bug with joins.