findNodeById static method

ElectricalNode? findNodeById(
  1. ElectricalNode? root,
  2. String id
)

Find a node by ID in the tree

Implementation

static ElectricalNode? findNodeById(ElectricalNode? root, String id) {
  if (root == null) return null;
  if (root.id == id) return root;

  return root.map(
    source: (node) => _findInChildren(node.children, id),
    protection: (node) => _findInChildren(node.children, id),
    panel: (node) => _findInChildren(node.children, id),
    load: (_) => null,
  );
}