I did this experiment few months ago to prepare me to the next feature I was going to implement at job.

This is a recursive table, a main group can contain criterions, segments and others groups and the same for all others groups inside.

Demo:

Or you can clone this repository: https://github.com/bertrandg/recursive-directive

Production version:

You can test the production version here: this-is-big.com

This version is more complexe because all changes are instantly saved and some others things..

this-is-big.com - Segment builder

Next step:

Next, I’m gonna add the drag & drop feature between element inside a same groug and then accross level.