implement new system for creating TreeNode struct
refactoring