/**
 * Recursively searches an ADF node tree for a node with the given localId.
 * Works with plain JSON ADF (no ProseMirror dependency).
 * Returns the node if found, or undefined if not found.
 */
export function findNodeByLocalId(node, localId) {
  if (node.attrs && typeof node.attrs === 'object' && node.attrs.localId === localId) {
    return node;
  }
  if (Array.isArray(node.content)) {
    for (const child of node.content) {
      const found = findNodeByLocalId(child, localId);
      if (found) {
        return found;
      }
    }
  }
  return undefined;
}