Factorize filtering part, added unittest
Added makeTree to make pattern bank in PatternGenerator