The interesting function is repair, which compares the expression for e.g. z11 with the objective adder expression for z11. If we can't find a node with the objective expression, we recurse into the sub-expressions and try repair those.
The usual way to get a tree of nested structs from an Ecto query is with preload. The preload option lets you load associations for an Ecto schema, either by issuing a separate query: