def get_parentid(current_depth, root, dir):
    # special case for the 'root' of the tree
    # because we don't want a cryptic root-name
    if current_depth == 0:
        return root

    # looking for parent directory
    # e.g. /home/user1/mp3/folder1/parent_folder/current_folder
    # get 'parent_folder'

    search_string = os.path.join(root, dir)
    pos2 = search_string.rfind('/')
    pos1 = search_string.rfind('/', 0, pos2)
    parent_dir = search_string[pos1 + 1:pos2]
    parentid = str(current_depth - 1) + '_' + parent_dir.replace(" ", "_") + '+++' + crc32(root)
    return parentid
    # TODO: catch error
dataset/ETHPy150Open caesar0301/treelib/examples/folder_tree.py/get_parentid/original