Issue
Trying to open the sub-category gives error "Multiple TreeView nodes have the same ID. IDs must be unique."

Click on any sub-category

Possible Solution

flattenTree also returns the first root element of sub category which is already in main tree that gives duplicate id error.