Refactoring to divide tree nodes into ParentNodes and LeafNodes