# flattenTree (@salmonui/data-grid/engine/tree)

> The flattenTree function of @salmonui/data-grid/engine/tree: Nested rows (childrenField arrays) as one flat pre-order array, rows by reference (never copied). Iterative, so deep trees never overflow the stack; a row that contains itself (a cycle in the nesting) is emitted once and its looping child skipped (onIssue with kind cycle).

Canonical: https://salmonui.dev/docs/reference/data-grid/engine-tree/flattenTree

```ts
import { flattenTree } from '@salmonui/data-grid/engine/tree';
```

Entry index: https://salmonui.dev/docs/reference/data-grid/engine-tree (Markdown with every symbol of the entry: https://salmonui.dev/docs/reference/data-grid/engine-tree.md).

## Reference

Kind: function

```ts
function flattenTree<Row>(roots: readonly Row[], childrenField: string, onIssue?: (issue: TreeIssue) => void): Row[];
```

Nested rows (`childrenField` arrays) as one flat pre-order array, rows by
reference (never copied). Iterative, so deep trees never overflow the
stack; a row that contains itself (a cycle in the nesting) is emitted once
and its looping child skipped (`onIssue` with kind `cycle`).
