# xarray.DataTree.filter

#### DataTree.filter(filterfunc)[[source]](https://github.com/pydata/xarray/blob/main/xarray/core/datatree.py#L1634-L1661)

Filter nodes according to a specified condition.

Returns a new tree containing only the nodes in the original tree for which fitlerfunc(node) is True.
Will also contain empty nodes at intermediate positions if required to support leaves.

* **Parameters:**
  **filterfunc** (`function`) – A function which accepts only one DataTree - the node on which filterfunc will be called.
* **Returns:**
  [`DataTree`](xarray.DataTree.html.md#xarray.DataTree)

#### SEE ALSO
[`match`](xarray.DataTree.match.html.md#xarray.DataTree.match), [`pipe`](xarray.DataTree.pipe.html.md#xarray.DataTree.pipe), [`map_over_datasets`](xarray.map_over_datasets.html.md#xarray.map_over_datasets)
