I have a list of numbers like [1, 2, 2, 3, 3, 2, 3, 3, 4] which I need to convert into a tree, like below:
1
/ | \
2 2 2
/ \ / \
3 3 3 3
\
4
Note: within the list, each number cannot be +2 or more than +2 compared to the preceding value.