eliminate a bunch of code duplication in ParseTreePattern