Designing trees out of lists?

On a web tool that I'm working on, I need to allow the user to navigate through a flat list of data and create a tree out of it. The user is a backend admin who is trained to use the tool.

Example

I have a list of data. Say,

  • Demographic_Men
  • Demographic_Male
  • Demographic_Women
  • Demographic_Female

The user needs to create a tree out of this list as follows: enter image description here
Where Male comprises of Male and Men and Female comprises of Women and Female.

The solution

The solution that I have come up with for the problem is as follows

enter image description here
This allows the user to add and create a root and then add children to it. These children are then mapped to Demographic_Men, Demographic_Male... etc accordingly.

The problem
The problem with this approach is that it doesn't scale well in the case of several nested children. Currently trees with just 2 nested children are displayed using accordions. Is there a design pattern for this or some similar problem?
Sorry if the question is confusing. I'm basically trying to create and map trees out of a list of data.