Refactor of Tree. Move internal classes to the dedicated files.