title: Delete property from object without knowing depth or parent properties
body: <p>I currently have a nested javascript object of unknown depth.  The object is generated purely dynamically, so I don't know the names of the parents of the property I want to delete  ( I could rework some stuff to get them If I Have To, but I'm trying to avoid that).</p>
  
  <p>I currently have a function called <code>search_tree(name)</code> that searches through all the properties of the object until it finds a property <code> name : "name" </code>, and then returns that object for adding data at that location of the tree.</p>
  
  <p>However, I now need to delete that object from the tree, and have not yet gotten it to work.  I have tried: </p>
  
  <pre><code>obj = search_tree(name);
  delete obj;
  </code></pre>
  
  <p>and that doesn't work, I'm assuming because obj isn't actually the object in the tree, but a reference to it?</p>
  
  <pre><code>delete search_tree(name);
  </code></pre>
  
  <p>also yielded no results.  Can this be done in this way, or will I need to alter the <code>search_tree</code> function to somehow return the heritage as well (or just make a different one)?  Thanks</p>
  
  <p><b>The code from search_tree</b></p>
  
  <pre><code>function search_tree(element, matchingName){
       if(element.name == matchingName){
            return element;
        }else if (element.children != null){
              var result = null;
              for(var child in element.children){
                   result = searchTree(element.children[child], matchingName);
              }
              return result;
        } else {
              return null;
        }
  }
  </code></pre>
  
  <p>Just realized this function may be a bit unclear without explanation.  Each object in the tree has a child object called "children," in which any number of other objects will be stored.  I added the extra "children" layer because the objects often have child objects that I do not want to be searched through as part of the tree.  Element is the object being searched through</p>