# Product structure

> Use this feature to manage and manipulate the product structure of 3D scenes, including creating hierarchies, sorting occurrences, and optimizing for performance.

API functions:

* [scene.getChildren](/asset-transformer-sdk/2026.4/api/python/scene_functions.md#getchildren)
* [scene.getParent](/asset-transformer-sdk/2026.4/api/python/scene_functions.md#getparent)
* [scene.setParent](/asset-transformer-sdk/2026.4/api/python/scene_functions.md#setparent)
* [scene.getOccurrenceName](/asset-transformer-sdk/2026.4/api/python/scene_functions.md#getoccurrencename)

Product structure is the scene hierarchy of [occurrences](./../scene/occurrence). It can be seen as a tree where we can go down to the leaf using [scene.getChildren](../../api/python/scene_functions#getchildren) and go up to the root using [scene.getParent](../../api/python/scene_functions#getparent).

We can manipulate this product structure to change order and parenting relations between occurences.

> **Note:**
>
> The most complex the product structure is, the less performant will be algorithms to search something in the scene. A complex hierarchy can also have an impact in terms of real time rendering performances. Cleaning and simplifying a complex product structure is an important process to export performant 3D assets.

## Code example

### Create new occurrences

Let's take an example where we create a new product structure from scratch to match the following tree:

```py
Root
|- zz
|-  |- t
|-  |- n
|- a
|- b
```

```python title="Python"
def createTestProductStructure():
    root = scene.getRoot()
    zz_occurrence = scene.createOccurrence(name="zz", parent=root)
    t_occurrence = scene.createOccurrence(name="t", parent=zz_occurrence)
    n_occurrence = scene.createOccurrence(name="n", parent=zz_occurrence)
    a_occurrence = scene.createOccurrence(name="a", parent=root)
    b_occurrence = scene.createOccurrence(name="b", parent=root)

```

### Print the hierarchy tree

We want to be able to print the name of each occurrence and have the same representation in the console than the structure described above.

```python title="Python"
# Go through the product structure using "depth first" recursive method
def dfPrintOccurrencesName(offset, occurrence):
    print(offset + scene.getOccurrenceName(occurrence))
    offset = offset + " |- "
    for child in scene.getChildren(occurrence):
        dfPrintOccurrencesName(offset, child)

```

### Manipulate the product structure

We want to manipulate the created hierarchy to sort the occurrences based on the alphabetical order of their names.

```python title="Python"
# Sort a product structure based on occurrences name alphabetical order
def sortOccurrencesRecursively(occurrence):

    children = scene.getChildren(occurrence)
    if not children:
        return

    names = core.getProperties(children, "Name")  # This built-in method retrieve all the names of an occurrence list
    children_with_names = zip(children, names)
    sorted_children_with_names = sorted(children_with_names, key=lambda x: x[1])
    sorted_children = [child for child, name in sorted_children_with_names]
    for child in sorted_children:
        sortRecursively(child)
        scene.setParent(child, occurrence)

```

#### Output

```py
Root
|- a
|- b
|- zz
|-  |- n
|-  |- t
```
