returns the root node of tree as a Tree object.


returns a Tree object containing the nodes of tree down to level n.


  • RootTree[Tree[data,{subtree1,subtree2,}] returns Tree[data,{}].
  • RootTree[Tree[data,None]] gives Tree[data,None].
  • RootTree[tree,n] removes all subtrees on levels below level n.
  • In RootTree[tree,n], the level n can be any machine integer or Infinity.
  • A positive level n+1 consists of all subtrees of tree that are children of subtrees on level n.
  • Level 0 corresponds to the root of the tree.
  • Level -1 corresponds to the leaves.
  • A negative level -(n+1) consists of all subtrees whose children are on levels -1, -2, , -n, with highest level -n.


open allclose all

Basic Examples  (3)

Extract the root of a tree:

Remove all subtrees below level 1:

Remove the leaves, keeping nodes down to level -2:

Options  (9)

Styling Individual Tree Elements  (2)

Specify the label for the generated tree element:

Specify labels and styles for subtrees by position:

Styling Entire Tree  (4)

Specify labels and styles for all subtrees:

Specify the base style:

Specify the style for both the edges and the edges of the tree elements:

Specify the base style and styles for individual tree elements:

Tree Layout and Graphics Options  (3)

Specify the orientation for the root:

Specify a named embedding:

Specify Graphics options:

Properties & Relations  (4)

RootTree[tree] gives Tree[TreeData[tree],None] when TreeChildren[tree] gives None:

RootTree[tree] gives Tree[TreeData[tree],{}] when TreeChildren[tree] gives a list:

RootTree[tree] gives Tree[TreeData[tree],<||>] when TreeChildren[tree] gives an association:

RootTree[tree,-1] gives the whole tree:

Wolfram Research (2022), RootTree, Wolfram Language function,


Wolfram Research (2022), RootTree, Wolfram Language function,


Wolfram Language. 2022. "RootTree." Wolfram Language & System Documentation Center. Wolfram Research.


Wolfram Language. (2022). RootTree. Wolfram Language & System Documentation Center. Retrieved from


@misc{reference.wolfram_2022_roottree, author="Wolfram Research", title="{RootTree}", year="2022", howpublished="\url{}", note=[Accessed: 09-August-2022 ]}


@online{reference.wolfram_2022_roottree, organization={Wolfram Research}, title={RootTree}, year={2022}, url={}, note=[Accessed: 09-August-2022 ]}