# Fumadocs Core (the core library of Fumadocs): Page Tree Utils
URL: /docs/headless/utils/page-tree
Source: https://raw.githubusercontent.com/fuma-nama/fumadocs/refs/heads/main/apps/docs/content/docs/headless/utils/page-tree.mdx

Common utilities to interact with page tree.

## Usage [#usage]

See [Definitions](/docs/headless/page-tree) to learn more about Page Tree.

```ts
import {
  findNeighbour,
  findSiblings,
  getPageTreeRoots,
  findParent,
  findPath,
  type Root,
} from 'fumadocs-core/page-tree';

const pageTree: Root = {
  // ...the root of page tree
};

// Get neighbours of a page
const neighbours = findNeighbour(pageTree, '/url/to/page');

// Get a list of root folders
const roots = getPageTreeRoots(pageTree);

// Get the sibling nodes of a page
const siblings = findSiblings(pageTree, '/url/to/page');

// Get the parent node of a page
const parent = findParent(pageTree, '/url/to/page');

// Find the path to the first matching node
const path = findPath(
  pageTree.children,
  // matcher
  (node) => node.type === 'page' && node.url === '/url/to/page',
);
```