# `Minga.SystemObserver.TreeNode`
[🔗](https://github.com/jsmestad/minga/blob/main/lib/minga/system_observer/tree_node.ex#L1)

Render-oriented tree node derived from flat SystemObserver snapshots.

SystemObserver keeps snapshots in a flat map keyed by PID because that is cheap to collect and easy to sample over time. The Observatory derives this tree when it needs hierarchy for rendering.

# `t`

```elixir
@type t() :: %Minga.SystemObserver.TreeNode{
  children: [t()],
  depth: non_neg_integer(),
  pid: pid(),
  snapshot: Minga.SystemObserver.ProcessSnapshot.t()
}
```

# `build_tree`

```elixir
@spec build_tree(%{required(pid()) =&gt; Minga.SystemObserver.ProcessSnapshot.t()}) ::
  t() | nil
```

Builds a supervision tree from a flat `%{pid => ProcessSnapshot.t()}` map.

Returns `nil` when the snapshot has no root process. Children whose parent is missing from the map are ignored because they cannot be placed in the rendered tree safely.

# `flatten`

```elixir
@spec flatten(t() | nil) :: [t()]
```

Returns the tree as a pre-order list of nodes.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
