# get\_parent\_map\_chains

Generates a dictionary of all the [MaciDataObj's](/docs/maci/object.md) currently mapped parent attribute name references to its children, and returns a dict of the maps with the values represented in a chain-like structure using lists.

Useful if it is desired to view all parent attribute names with their interconnected child mappings following each other in order.

{% hint style="info" %}
data.get\_parent\_map\_chains()  ->  dict\[str, list\[str]] | list\[str]
{% endhint %}

\
*Basic Example getting all current parent mappings of the* [*MaciDataObj*](/docs/maci/object.md) *as chains with no parameters*

```python
dict_data = data.get_parent_map_chains()
```

In this example, we simply use the get\_parent\_map\_chains method on the [MaciDataObj](/docs/maci/object.md) to get a generated dict of all the current parent attribute names with their child mappings, currently held inside the maci object, represented as a dictionary, and assign the returned data to a variable.<br>

*Example output of a basic parent map with the children following it as a chain*

```python
{'attr1': ['attr1', 'attr2', 'attr3', 'attr4', 'attr5']}
```

Parent maps have their own parent key name matching its attribute name and value being a list of attribute names starting with the parent as the first name, then children following one after another.&#x20;

You may also pass in the known parent key name of the chain you wish to retrieve using the "parent\_attr" optional positional parameter. <br>

*Example passing the name "attr1" in the method to receive its chain output*

```python
data.get_parent_map_chains('attr1')
```

```python
['attr1', 'attr2', 'attr3', 'attr4', 'attr5']
```

As mentioned in the language section [Map Assignment Glyph](https://docs.macilib.org/docs/maci/language/v1.0.0#map-assignment-glyph), It is possible to have a name be a parent and a child simultaneously. This is evaluated whether a child that is following a parent also has children following it and they are all interlinked together one after another. However, if it is just a parent and not a child, it will gain its own key name with its own chain.

If a child breaks off from the chain being reassigned to a new value and has children following it, it will gain its own chain separate from the one it was linked to. In addition, if a child happens to break off from the chain by being unmapped (See [unmap\_attr](/docs/maci/object/methods/unmap_attr.md)) or deleted, the child will just be released from the chain mapping. However, if the child that broke off was unmapped or deleted and was also a parent, the next child will inherit the role of a parent if it also has children and gain its own chain.<br>

*Example output of "attr3" breaking off chain by reassignment gaining its own chain*

```python
{'attr1': ['attr1', 'attr2'], 'attr3': ['attr3', 'attr4', 'attr5']}
```

*Example output of "attr3" breaking off chain by unmap or deletion and next child gains its own chain*

```python
{'attr1': ['attr1', 'attr2'], 'attr4': ['attr4', 'attr5']}
```

#### key-ring exception

If a chain attempts to generate with multiple children mapped to the same parent, an exception will be thrown by default stating it cannot build a chain with multiple children linked to the same parent. That behavior would describe more of a key-ring like structure over a chain. See [Map Assignment Glyph](https://docs.macilib.org/docs/maci/language/v1.0.0#map-assignment-glyph) for more on that. If you wish to ignore that check, use [dup\_link\_check](https://docs.macilib.org/docs/maci/object/methods/get_parent_map_chains#dup_link_check-bool) parameter to disable it, but your chains may break off into separate chains if encountered as explained above.

For more information on the mapping concept, see [Map Assignment Glyph](https://docs.macilib.org/docs/maci/language/v1.0.0#map-assignment-glyph) in the language section and [map\_attr](/docs/maci/object/methods/map_attr.md).

### partner methods

Methods that provide related utility to this method

[map\_attr](/docs/maci/object/methods/map_attr.md)  ->  Map an attribute name\
[unmap\_attr](/docs/maci/object/methods/unmap_attr.md)  ->  Unmap an attribute name

### parameters & arguments

Describes all parameter functionality and accepted data types

<details>

<summary>parent_attr:  str | None</summary>

Optional first positional parameter. Accepts strings or None. Default = None.

Use this parameter to retrieve a chain from a specific parent attribute name

</details>

<details>

<summary>dup_link_check:  bool</summary>

Optional parameter. Accepts booleans. Default = True.

Protects against duplicate child links being built to the parent. If disabled and a duplicate is found, it will still return chain(s), but will cut the chain's previous child links to the parent and only continue the chain from the last child to the parent and retain any chain links following the last child.

It is worth stating, this method does not break/affect the actual behavior of the attributes being linked together, as the get\_parent\_map\_chains method only fresh builds a representation of the attributes linked together in the form of a chain for your reference to help understand what attribute names are connected to each other. The true linking is controlled by other mechanics, and any real duplicate links are not affected as that is acceptable behavior.

</details>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.macilib.org/docs/maci/object/methods/get_parent_map_chains.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
