

def remove_head_directories(path, heads=1):

    def explode_path(path):
        (head, tail) = os.path.split(path)
        return ((explode_path(head) + [tail]) if (head and (head != path)) else [(head or tail)])
    exploded_path = explode_path(path)
    if (len(exploded_path) < (heads + 1)):
        return ''
    else:
        return os.path.join(*exploded_path[heads:])

dataset/ETHPy150Open bryancatanzaro/copperhead/setup.py remove_head_directories/original