title: JavaFX TreeView find TreeItem in any depth matching a given value
body: <blockquote>
    <p>I am trying to create a method that does what title says . Let's say i have the below TreeView , i want to add a search functionality , in which the user can give for example a value<code>desktop</code> and using that method to get the first TreeItem which has the given value <code>treeItem.getValue();</code></p>
  </blockquote>
  
  <p><strong>I need exactly this <code>treeView.getChildren_InAnyDepth_MatchingValue("value");</code>.</strong></p>
  
  <blockquote>
    <p>Let's say i want it to start searching from the root of the TreeView.</p>
  </blockquote>
  
  <p><a href="https://i.stack.imgur.com/EZQPR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EZQPR.png" alt="enter image description here"></a></p>
  
  <hr>
  
  <blockquote>
    <p>Java Code :</p>
  </blockquote>
  
  <pre><code>/**
  * Find the first TreeItem matching the given value
  * 
  * @param item
  */
  public TreeItem getTreeViewItem(TreeItem&lt;String&gt; item , String value) {
      if (item != null &amp;&amp; item.getValue().equals(value))
          return  item;
  
      for (TreeItem&lt;String&gt; child : item.getChildren())
          getTreeViewItem(child, value);
  
      return null;
  }
  </code></pre>
  
  <p><strong>The above code always returns null for some reason , i can't figure out 6 hours now .</strong></p>