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

# getNode

> **getNode**(`snapshot`, `path`): \{ `node`: `Node`; `path`: `Path`; \} \| `undefined`

Defined in: get-node.ts:32

Get the node at a given path.

The path can be either keyed (KeyedSegment + field name strings) or
indexed (numbers). Keyed segments are resolved by matching `_key`,
field name strings name a structural descent into the previous
node's children, and numbers are resolved by index.

The returned `path` always identifies the returned node: it's fully
keyed (numeric indices are converted to `KeyedSegment`s) and any
trailing segments in the input that point outside the value tree —
e.g. an object node's primitive field, or an annotation reached via
`'markDefs'` on a text block — are stripped so that
`getNode(snapshot, entry.path).node === entry.node`.

The walk stops when a string segment names a field that isn't the
current node's structural child array. Annotations live in
`markDefs` on a text block, alongside `children` rather than inside
it, so `getNode` resolves an annotation path to the enclosing text
block. Use `getAnnotation` to resolve the annotation itself.

## Parameters

### snapshot

`TraversalSnapshot`

### path

`Path`

## Returns

\{ `node`: `Node`; `path`: `Path`; \} \| `undefined`