in reply to Walking a boolean tree to produce matching inputs
Have a look at this recent thread: Optimize a generic boolean expression.