title: Change object property in nested array
body: <p>I have an array:</p>
  <pre><code>   const array = [
        { id: 1, parent_id: 0, visible: true },
        { id: 2, parent_id: 0, visible: true },
        { id: 3, parent_id: 1, visible: true },
        { id: 4, parent_id: 3, visible: true },
        { id: 5, parent_id: 4, visible: true },
        { id: 6, parent_id: 4, visible: true },
        { id: 7, parent_id: 3, visible: true },
        { id: 8, parent_id: 2, visible: true }
      ]
  </code></pre>
  <p>I want to create a function with arguments ID and ARRAY, that return new array with VISIBLE = FALSE for this ID and every nested child by PARENT_ID.</p>
  <p>My effort is like this</p>
  <pre><code>const result = []
  
  const findFitstHandler = (id, arr) =&gt; {
    let j
    for (let i in arr) {
      if (arr[i].id === id) {
        result.push(arr[i].id)
        j = arr[i].id
      }
    }
    findNested(j, arr)
  
    return array.map(item =&gt; {
      if (result.includes(item.id)) {
        return {
          ...item,
          visible: false
        }
      } else {
        return item
      }
    })
  }
  
  const findNested = (id, arr) =&gt; {
    for (let i in arr) {
      if (arr[i].parent_id === id) {
        result.push(arr[i].id)
        findNested(arr[i].id, arr)
      }
    }
  }
  </code></pre>
  <p>I'm sure there is a more elegant solution. Please, help me</p>