JSFiddle - React, Tailwind, and code Playground

HTML

<script src="//cdnjs.cloudflare.com/ajax/libs/jstree/3.0.9/jstree.min.js"></script>
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/jstree/3.0.9/themes/default/style.min.css">
<input type="file" id="files" name="files[]" multiple webkitdirectory />
<div id="tree"></div>

JavaScript

var input = document.getElementById('files');
 var narr = [];
var fileICON = "http://imdbnator.com/test/images/file.png";

//when browse button is pressed
 input.onchange = function (e) {
     var dummyObj = [];
     var files = e.target.files; // FileList
     for (var i = 0, f; f = files[i]; ++i) {
         var fname = './' + files[i].webkitRelativePath;
         narr = $.merge(dummyObj, (cat(fname)));
     }

     treeJSON = narr.getUnique(); // getting the JSON tree after processing input
     console.log(JSON.stringify(treeJSON));

     //creating the tree using jstree
     
     $('#tree')
         .jstree({
         'core': {
             'check_callback': true,
                 'data': function (node, cb) {
                 cb.call(this, treeJSON);
             }
         }
     });
     var tree = $('#tree').jstree(true);
     tree.refresh();
 };

//get unqiue array function
 Array.prototype.getUnique = function () {
     var o = {}, a = [];
     for (var i = 0, l = this.length; i < l; ++i) {
         if (o.hasOwnProperty(JSON.stringify(this[i]))) {
             continue;
         }
         a.push(this[i]);
         o[JSON.stringify(this[i])] = 1;
     }
     return a;
 };

 // categorizing function which converts each ./Files/Root/File.jpg to a JSON

 var objArr = [];
 var folderArr = [];

 function cat(a) {
     if (!a.match(/\/(.+?)\//)) {
         var dummyObj = {};
         var fname = a.match(/\/(.*)/)[1];
         dummyObj.id = fname;
         dummyObj.text = fname;
         if (folderArr === undefined || folderArr.length == 0) {
             dummyObj.parent = '#';
         } else {
             dummyObj.parent = folderArr[(folderArr.length) - 1];
             dummyObj.icon = fileICON; // add extention and icon support
         }
         objArr.push(dummyObj);
         return objArr;
     } else {
         if (a.charAt(0) == '.') {
             var dummyObj = {};
             var dir1 = a.match(/^.*?\/(.*?)\//)[1];
             dummyObj.id =...