'Loads recursively all files and folders within the given folder
and its subfolders and returns jstree representation
of its structure.'

def __create_jstree(self, directory, disable='folders'):

    userdir_jstree = None
    jstree_paths = []
    if os.path.exists(directory):
        for (dirpath, dirnames, filenames) in os.walk(directory):
            for dirname in dirnames:
                dir_path = os.path.relpath(os.path.join(dirpath, dirname), directory)
                dir_path_hash = hashlib.sha1(unicodify(dir_path).encode('utf-8')).hexdigest()
                disabled = (True if (disable == 'folders') else False)
                jstree_paths.append(jstree.Path(dir_path, dir_path_hash, {'type': 'folder', 'state': {'disabled': disabled}, 'li_attr': {'full_path': dir_path}}))
            for filename in filenames:
                file_path = os.path.relpath(os.path.join(dirpath, filename), directory)
                file_path_hash = hashlib.sha1(unicodify(file_path).encode('utf-8')).hexdigest()
                disabled = (True if (disable == 'files') else False)
                jstree_paths.append(jstree.Path(file_path, file_path_hash, {'type': 'file', 'state': {'disabled': disabled}, 'li_attr': {'full_path': file_path}}))
    else:
        raise exceptions.ConfigDoesNotAllowException('The    given    directory    does    not    exist.')
    userdir_jstree = jstree.JSTree(jstree_paths)
    return userdir_jstree
