# 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="https://4112750745-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYVrI6eFo60Gwsn2A05qA%2Fuploads%2FCRWE4hmhzRj3Gy1e263Y%2FhatTreeLinking1.png?alt=media&#x26;token=3cfb8681-bb02-4f57-996a-0f6b265cbc14" 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="https://4112750745-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYVrI6eFo60Gwsn2A05qA%2Fuploads%2F52L2d011cpRPDSUt7KTr%2FhatTreeLinking2.png?alt=media&#x26;token=c563c454-2c04-4240-8692-aa49a59f4306" 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="https://4112750745-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYVrI6eFo60Gwsn2A05qA%2Fuploads%2FMqIKXZBugAVDYOYcgvvI%2FhatTreeLinking3.png?alt=media&#x26;token=7d021341-6242-44f2-8d69-d626003ab9b5" 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](https://docs.hatsprotocol.xyz/for-developers/hats-protocol-for-developers/linking-hats-trees) 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.*
