# xarray.DataTree.filter_like

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

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('0b165abf-ffa0-42d2-bde8-033b92688ef2','7b6203f1-a68e-45d3-aff5-551303bd06d8','077e6cdb-29ac-4e04-9dcd-fc866411fe57','../lite/tree/../notebooks/index.html?path=b239f94d_467f_4f7d_a812_8631ff26e4e6.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="077e6cdb-29ac-4e04-9dcd-fc866411fe57" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('0b165abf-ffa0-42d2-bde8-033b92688ef2','077e6cdb-29ac-4e04-9dcd-fc866411fe57')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('0b165abf-ffa0-42d2-bde8-033b92688ef2','077e6cdb-29ac-4e04-9dcd-fc866411fe57')">Open In Tab</button></div><div id="7b6203f1-a68e-45d3-aff5-551303bd06d8" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
