Refactor out tree related classes into its own modules