deletes the subtree of tree at the position specified by pos.


deletes subtrees at several positions.


represents an operator form of TreeDelete that can be applied to a tree.


  • TreeDelete allows removal of subtrees at any position in a Tree object.
  • TreeDelete[tree,{i,j,}] deletes the subtree at position {i,j,}.
  • TreeDelete can use the position specifications returned by TreePosition as well as extended forms as used in functions such as TreeExtract and TreeReplacePart. »
  • An individual position specification pos can be given as {part1,part2,}, where part specifications parti include:
  • ithe i^(th) child
    -ithe i^(th) child from the end
    {i1,i2,}the list of children with part numbers i1, i2,
  • In TreeDelete[tree,{p1,p2,}], {p1,p2,} is interpreted as a list of individual position specifications if all the pi are lists. Otherwise, {p1,p2,} will be taken to be an individual position specification. »
  • TreeDelete[pos][tree] is equivalent to TreeDelete[tree,pos].


open allclose all

Basic Examples  (3)

Delete the second child of a tree:

Delete a subtree at any position:

Delete multiple subtrees:

Use the operator form of TreeDelete:

Properties & Relations  (7)

Subtrees can be deleted, as well as inserted or replaced:

Construct a tree from the heads in an expression:

TreeDelete deletes a subtree of a tree:

This corresponds to deleting a subexpression of an expression:

Delete can delete subexpressions directly:

If pos is not a list, pos and {pos} are equivalent specifications:

Deleting position {} deletes the whole tree:

TreeDelete ignores repeated positions:

TreeDelete can use the lists of positions returned by TreePosition:

These are the subtrees returned by TreeExtract:

TreeDelete[tree,{p1,p2,}] treats {p1,p2,} as a list of individual position specifications if all the pi are lists:

For {{1,2},{3,4}}, the subtrees at positions {1,2} and {3,4} are deleted:

If any pi is not a list, {p1,p2,} is treated as a list of part specifications:

For {{{1,2},{3,4}}}, parts 3 and 4 of parts 1 and 2 are deleted:

Possible Issues  (1)

TreeDelete[tree,{}] does not delete any subtrees because the list of positions is empty:

TreeDelete[tree,{{}}] deletes position {}, which corresponds to the whole tree:

Wolfram Research (2021), TreeDelete, Wolfram Language function, (updated 13).


Wolfram Research (2021), TreeDelete, Wolfram Language function, (updated 13).


Wolfram Language. 2021. "TreeDelete." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 13.


Wolfram Language. (2021). TreeDelete. Wolfram Language & System Documentation Center. Retrieved from


@misc{reference.wolfram_2021_treedelete, author="Wolfram Research", title="{TreeDelete}", year="13", howpublished="\url{}", note=[Accessed: 22-May-2022 ]}


@online{reference.wolfram_2021_treedelete, organization={Wolfram Research}, title={TreeDelete}, year={13}, url={}, note=[Accessed: 22-May-2022 ]}