### File

`packages/components/eui-tree/eui-tree-helper.ts`

### Description

Utility class for navigating and querying hierarchical tree data structures. Provides methods to locate nodes by value, retrieve paths, and extract items from tree data. Supports custom identifier keys for flexible node matching across different tree schemas. Commonly used with eui-tree component for programmatic tree manipulation and node lookup.

### Basic Usage

Example :

    const treeData: TreeDataModel = [
      {
        node: { treeContentBlock: { id: '1', label: 'Root' } },
        children: [
          { node: { treeContentBlock: { id: '1.1', label: 'Child' } } }
        ]
      }
    ];

    const helper = new EuiTreeHelper(treeData);

    // Get path to a node by ID
    const path = helper.getPath('1.1', 'node.treeContentBlock.id');
    // Returns: '0.0'

    // Get multiple paths
    const paths = helper.getPaths(['1', '1.1'], 'node.treeContentBlock.id');
    // Returns: ['0', '0.0']

    // Get actual tree items
    const items = helper.getItems(['1.1'], 'node.treeContentBlock.id');
    // Returns: [TreeItemModel]

### With Custom Identifier

Example :

    // Tree with custom structure
    const customTree = [
      { node: { customId: 'abc', label: 'Item' } }
    ];

    const helper = new EuiTreeHelper(customTree);
    const path = helper.getPath('abc', 'node.customId');

### Accessibility

- Helper methods are synchronous and non-blocking
- No direct accessibility concerns (utility class)

### Notes

- Path format uses dot notation: '0.2.1' (indices at each level)
- Supports deeply nested tree structures
- Deep equality comparison for complex value matching
- Identifier key uses dot notation for nested properties
- Returns null/empty array if no matches found

### Index

###### Methods
Public getItems Public getPath Public getPaths

### Constructor

`constructor(treeData: TreeDataModel)`
Parameters :
Name | Type | Optional
treeData | `TreeDataModel` | No

### Methods

Public getItems
`getItems(values: Array, identifierKey?: string)`
Retrieves the actual TreeItemModel objects for nodes matching the provided values. Returns full node data including children and metadata. Parameters :
Name | Type | Optional | Description
values | `Array<any>` | No | Array of values to search for in the tree
identifierKey | `string` | Yes | Dot-notation property path to use for matching
Returns : `Array<TreeItemModel>` Array of TreeItemModel objects for matched nodes

Public getPath
`getPath(value: any, identifierKey: string)`
Retrieves the path string for a single node matching the provided value. Path format uses dot notation with indices (e.g., '0.2.1' for first child, third grandchild, second great-grandchild). Parameters :
Name | Type | Optional | Default value | Description
value | `any` | No |  | Value to search for in the tree
identifierKey | `string` | No | `'node.treeContentBlock.id'` | Dot-notation property path to use for matching (e.g., 'node.treeContentBlock.id'). Default: 'node.treeContentBlock.id'
Returns : `string` Path string to the matched node, or null if not found

Public getPaths
`getPaths(values: Array, identifierKey?: string)`
Retrieves path strings for multiple nodes matching the provided values. Returns paths in the order nodes are found during tree traversal. Parameters :
Name | Type | Optional | Description
values | `Array<any>` | No | Array of values to search for in the tree
identifierKey | `string` | Yes | Dot-notation property path to use for matching
Returns : `Array<string>` Array of path strings to matched nodes

# results matching ""

# No results matching ""