title: How to get subtree of json containing known object
body: <p>I want to extract the subtree containing the focused window from <code>i3-msg -t get_tree</code> with <code>jq</code>. I know the focused window can be found with </p>
  
  <p><code>i3-msg -t get_tree | jq ".. | (.nodes? // empty)[] | select(.focused == true)"</code></p>
  
  <p>A simple example would be:</p>
  
  <pre><code>{
    "node": [
      {
        "node": {
          "foo": "bar"
        }
      },
      {
        "node": {
          "foo": "foo"
        }
      }
    ]
  }
  </code></pre>
  
  <p>And the output should if searching for a <code>node</code> containg <code>.foo == "bar"</code> should return</p>
  
  <pre><code>{
    "node": [
      {
        "node": {
          "foo": "bar"
        }
      }
    ]
  }
  </code></pre>
  
  <p>But I can't seem to find a proper method to extract the subtree spanning from the root to this node.</p>