def get_parent_id(structure_id_path, root=997):
    """
    Given a path (as a list of structure ids) to a specific structure,
    return the id of the parent structure

    Parameters
    ----------
    structure_id_path : list
        list of ints defining the path to a region (which is the last element)

    root : int (optional)
        Value for the root (whole brain) structure that has no parent.

    Returns
    -------
    int or None :
        id of the parent structure (or None if no parent)
    """

    if structure_id_path == [root]:
        return None
    else:
        return int(structure_id_path[-2])