# Linking Trees Together

This powerful feature lets you graft two separate Hats trees together, by linking the Top Hat from one tree to a hat from another tree. Hats trees that have been linked can then be unlinked later.

**Example use cases for linking Hats trees include:**

* Onchain organizational mergers (e.g. one DAO joining another DAO)
* Emergent subgroups (e.g., subDAOs can create their own Hats tree and then petition to link to the main DAO anization upon maturity, and unlink again to go independent)
* Enabling experimentation with Hats within subgroups before scaling to the whole organization (e.g. enable a subgroup to build out its own Hats tree and try out new Hats features with different authorities and responsibilities before merging into organization's main tree)
* "Refactor" your organization (e.g. fork your Hats tree to try different Hats configurations before merging with the main tree)

## Overview

At a high-level the process of tree linking looks like this:&#x20;

Initially, two separate Hats trees exist, each with their own respective Top Hats, as seen in the diagram below.

<figure><img src="/files/gOog9iKJKHg6ogi9EAuh" alt=""><figcaption></figcaption></figure>

Hats Tree 2 requests to link to a specific hat in Hats Tree 1. Effectively the Top Hat from Tree 2 asks a specific hat from Tree 1, *"hat, ser - will you be my admin hat?"*

<figure><img src="/files/SMNWBxudKso3FClXDN3z" alt=""><figcaption></figcaption></figure>

If approved, Tree 2 links, or "grafts", to Tree 1. The approving hat becomes the admin of the Top Hat from Tree 2.&#x20;

The Top Hat from Tree 2, along with its associated branch, can be unlinked from Tree 1 at any point in the future, thereby returning back to the initial state of having two separate Hats trees.

<figure><img src="/files/8iU0sQfGnaK8MmgMEXV4" alt=""><figcaption></figcaption></figure>

When a link between these two trees is created, as seen in the diagram above, the level 2 hat from Tree 1 becomes the admin for the Top Hat of tree 2, and therefore the Top Hat of Tree 2 effectively becomes a level 3 hat in Tree 1. The previous Top Hat from the now nonexistent Tree 2 will then hold the same properties as as any other hat in Tree 1, with one distinction: the Top Hat and its child hats can be unlinked from Tree 1 at any point in the future, thereby returning back to the initial state of having two separate Hats trees.

## Digging Deeper

For more technical details on tree linking, see the [Linking Hats Trees](/for-developers/hats-protocol-for-developers/linking-hats-trees.md) page within the "For Developers" section of these docs.

## How to Link Trees Together

*Coming soon. Contact us at support \[at] hatsprotocol \[dot] xyz if you're looking to link two trees together and need some guidance.*


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.hatsprotocol.xyz/using-hats/linking-trees-together.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
