fix merge/flatten algorith with pure recursive JS
split flatten files into two flatten and flatten recursive
Merge pull request #2 from weblancaster/change-flatten-func

Update merge/flatten algorithm using recursive approach