> For the complete documentation index, see [llms.txt](/llms.txt).
> The full corpus is at [llms-full.txt](/llms-full.txt).

# getAncestors

> **getAncestors**(`snapshot`, `path`): `object`[]

Defined in: get-ancestors.ts:26

Get all ancestors of the node at a given path, from nearest to furthest.

For a path like [{_key:'t1'}, 'rows', {_key:'r1'}, 'cells', {_key:'c1'}],
the ancestors are (nearest first):
  [{_key:'t1'}, 'rows', {_key:'r1'}]
  [{_key:'t1'}]

Walks from root to the target in a single pass collecting each ancestor
as it goes.

Every ancestor is a `PortableTextBlock`: only text blocks and object
nodes can contain children.

## Parameters

### snapshot

`TraversalSnapshot`

### path

`Path`

## Returns

`object`[]