How I can change object by Id in nested array with childrens, and update state in React

How can i toggle isExpanded property on onClick by Id. I’m using React for this project.
Here is my json data structure.

const handleExpandOutlineItem = (id: string) => {}

here is my json data structure.

  {
    id: '1',
    title: 'Introduction to Programming',
    isExpanded: true,
    children: [
      {
        id: '1.1',
        title: 'What is programming?',
        isExpanded: false,
        children: [
          {
            id: '1.1.1',
            title: 'What is programming?',
            isExpanded: false,
            children: [],
          },
          {
            id: '1.1.2',
            title: 'What is programming?',
            isExpanded: false,
            children: [],
          },
        ],
      },
      {
        id: '1.2',
        title: 'Programming languages',
        isExpanded: false,
        children: [
          {
            id: '1.2.1',
            title: 'Programming languages',
            isExpanded: false,
            children: [],
          },
          {
            id: '1.2.2',
            title: 'Programming languages',
            isExpanded: false,
            children: [],
          },
        ],
      },
    ],
  },
]```

I trie to use recursion, but I should also update state