def getParent(path, num=1):
    """
    Find parent directory of a file or subdirectory

    @param path: filepath or subdirectory from which to find a parent
    @type path: string
    @param num: how many subdirectories to traverse before returning parent
    @type num: int

    @return: path to parent directory
    @rtype: string
    """
    for x in range(num):
        if "/" in path:
            path = path[:path.rindex("/")]

    return path