# 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('1e90be49-14c3-47d4-a5c4-5d818ec0e868','2c7e41f2-1d79-475e-8a49-a91b7b6ee682','2d374f1f-0366-4f3e-9e7e-cf1b5078eca3','../lite/tree/../notebooks/index.html?path=d5ead304_87ba_4e47_95b1_0e541278a980.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="2d374f1f-0366-4f3e-9e7e-cf1b5078eca3" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('1e90be49-14c3-47d4-a5c4-5d818ec0e868','2d374f1f-0366-4f3e-9e7e-cf1b5078eca3')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('1e90be49-14c3-47d4-a5c4-5d818ec0e868','2d374f1f-0366-4f3e-9e7e-cf1b5078eca3')">Open In Tab</button></div><div id="2c7e41f2-1d79-475e-8a49-a91b7b6ee682" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
