Refactoring the Tree and Pattern class hierarchies into Tree.scala