# How to find elements of the root namespace using Automator?

**URL:** https://forum.sensmetry.com/t/how-to-find-elements-of-the-root-namespace-using-automator/79
**Category:** How-to Guides
**Tags:** automator
**Created:** [May 22, 2025, 12:27pm UTC](https://forum.sensmetry.com/t/how-to-find-elements-of-the-root-namespace-using-automator/79 "2025-05-22T12:27:05Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![JaneM](https://avatars.discourse-cdn.com/v4/letter/j/dec6dc/32.png) [@JaneM](https://forum.sensmetry.com/u/JaneM)
#### Post date: [May 22, 2025, 12:27pm UTC](https://forum.sensmetry.com/t/how-to-find-elements-of-the-root-namespace-using-automator/79/1 "2025-05-22T12:27:05Z")

</div>

```auto
package A {
    package B {}
}

```

Say the above is my SysML v2 code - How can I check if an element is in the root namespace using Automator? E.g. I want to match package A but not package B.

---

<div class="post-metadata">

### Author: ![james\_frost](https://avatars.discourse-cdn.com/v4/letter/j/fbc32d/32.png) [@james\_frost](https://forum.sensmetry.com/u/james_frost)
#### Post date: [May 22, 2025, 12:28pm UTC](https://forum.sensmetry.com/t/how-to-find-elements-of-the-root-namespace-using-automator/79/2 "2025-05-22T12:28:19Z")

</div>

You can use `root_node.children.elements` - I hope this helps!

---

<div class="post-metadata">

### Author: ![JaneM](https://avatars.discourse-cdn.com/v4/letter/j/dec6dc/32.png) [@JaneM](https://forum.sensmetry.com/u/JaneM)
#### Post date: [May 22, 2025, 12:33pm UTC](https://forum.sensmetry.com/t/how-to-find-elements-of-the-root-namespace-using-automator/79/3 "2025-05-22T12:33:09Z")

</div>

Thanks, but what can I use as my root node? I want to search for nodes in the entire model, in all documents

---

<div class="post-metadata">

### Author: ![james\_frost](https://avatars.discourse-cdn.com/v4/letter/j/fbc32d/32.png) [@james\_frost](https://forum.sensmetry.com/u/james_frost)
#### Post date: [May 22, 2025, 12:33pm UTC](https://forum.sensmetry.com/t/how-to-find-elements-of-the-root-namespace-using-automator/79/4 "2025-05-22T12:33:25Z")

</div>

A good practice is to do the following:

```auto
(model, diagnostics) = syside.load_model([MODEL_FILE_PATH])

for doc in model.user_docs:
        with doc.lock() as locked:
            root_node = locked.root_node
            for child in root_node.children.elements...

```

---

<div class="post-metadata">

### Author: ![TiloWiklund](https://yyz2.discourse-cdn.com/flex008/user_avatar/forum.sensmetry.com/tilowiklund/32/17_2.png) [@TiloWiklund](https://forum.sensmetry.com/u/TiloWiklund)
#### Post date: [June 3, 2025, 9:50am UTC](https://forum.sensmetry.com/t/how-to-find-elements-of-the-root-namespace-using-automator/79/5 "2025-06-03T09:50:29Z")

</div>

You can also check if the owner has an owner  
`element.owner is None # <- is a root namespace`  
or  
`element.owner is not None and element.owner.owner is None # <- owner is a root namespace, i.e. this i a top level element.`
