# xarray.DataTree.filter_like

#### DataTree.filter_like(other)[[source]](https://github.com/pydata/xarray/blob/main/xarray/core/datatree.py#L1663-L1709)

Filter a datatree like another datatree.

Returns a new tree containing only the nodes in the original tree which are also present in the other tree.

* **Parameters:**
  **other** ([`DataTree`](xarray.DataTree.html.md#xarray.DataTree)) – The tree to filter this tree by.
* **Returns:**
  [`DataTree`](xarray.DataTree.html.md#xarray.DataTree)

#### SEE ALSO
[`filter`](xarray.DataTree.filter.html.md#xarray.DataTree.filter), [`isomorphic`](xarray.DataTree.isomorphic.html.md#xarray.DataTree.isomorphic)

### Examples

<div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesShowIframe('d5d693d7-9add-4284-9d42-5a3a7b14430b','5fb4a31d-0de2-4542-9bf1-031c284bdf60','43750c30-bc12-4371-946f-f3b6ec5ca249','../lite/tree/../notebooks/index.html?path=fe469a99_91fc_4270_b36a_17aa80448496.ipynb','None')">Try it in your browser!</button></div>
```pycon
>>> dt = DataTree.from_dict(
...     {
...         "/a/A": None,
...         "/a/B": None,
...         "/b/A": None,
...         "/b/B": None,
...     }
... )
>>> other = DataTree.from_dict(
...     {
...         "/a/A": None,
...         "/b/A": None,
...     }
... )
>>> dt.filter_like(other)
<xarray.DataTree>
Group: /
├── Group: /a
│   └── Group: /a/A
└── Group: /b
    └── Group: /b/A
```

<div id="43750c30-bc12-4371-946f-f3b6ec5ca249" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('d5d693d7-9add-4284-9d42-5a3a7b14430b','43750c30-bc12-4371-946f-f3b6ec5ca249')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('d5d693d7-9add-4284-9d42-5a3a7b14430b','43750c30-bc12-4371-946f-f3b6ec5ca249')">Open In Tab</button></div><div id="5fb4a31d-0de2-4542-9bf1-031c284bdf60" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
