How to expose inherited properties in tree-like structures

We have a tree structure where a property can be defined at an interior node of the tree and if the property is not defined for a node, then the value of the property value of its nearest ancestor that defines the property is used. In other words, we have inherited attributes. The question is, what is the best way to model such inheritance.

One way is to model it directly with an attribute per node. When queried, the value of the attribute does NOT reflect the value of any proper ancestor. Additionally, we can provide a link or a non-writable relationship that returns a resource that encapsulates the value of the property in the nearest ancestor that defines the property.

Is this the best way to model such inheritance?

1 Like

Attributes do not need to be name/value pairs, you can have any valid JSON object - as long as the internals of that object aren’t resources themselves.

Would you be able to give an example so I can better understand the use case?