function recursiveFind(hierarchicalObject, getChildren, findCondition) {
  if (findCondition(hierarchicalObject)) return hierarchicalObject;
  var children = getChildren(hierarchicalObject);
  var foundNode = children.find(findCondition);

  if (!foundNode) {
    var _iterator = _createForOfIteratorHelper(children),
        _step;

    try {
      for (_iterator.s(); !(_step = _iterator.n()).done;) {
        var child = _step.value;
        foundNode = recursiveFind(child, getChildren, findCondition);
        if (foundNode) break;
      }
    } catch (err) {
      _iterator.e(err);
    } finally {
      _iterator.f();
    }
  }

  return foundNode;
}
/**
 * Recursively find a particular object within a hierarchical dataset.
 * 
 * @param {object} hierarchicalObject The initial hierarchical object to start the recursive find.
 * @param {function} getChildren The callback function that gets the children items of the hierarchical object.
 * @param {function} findCondition The callback function that defines whether the object matches the condition to be returned or not.
 * @returns {object|null} The first object matching the conditions.
 */
Recursively find a particular object within a hierarchical dataset.

@param {object} hierarchicalObject The initial hierarchical object to start the recursive find.
@param {function} getChildren The callback function that gets the children items of the hierarchical object.
@param {function} findCondition The callback function that defines whether the object matches the condition to be returned or not.
@returns {object|null} The first object matching the conditions.
Recursively find a particular object within a hierarchical dataset . @param { object } hierarchicalObject The initial hierarchical object to start the recursive find . @param { function } getChildren The callback function that gets the children items of the hierarchical object . @param { function } findCondition The callback function that defines whether the object matches the condition to be returned or not . @returns { object|null } The first object matching the conditions .
function recursiveFind(hierarchicalObject, getChildren, findCondition) {
  if (findCondition(hierarchicalObject)) return hierarchicalObject;
  var children = getChildren(hierarchicalObject);
  var foundNode = children.find(findCondition);
  if (!foundNode) {
    var _iterator = _createForOfIteratorHelper(children),
        _step;
    try {
      for (_iterator.s(); !(_step = _iterator.n()).done;) {
        var child = _step.value;
        foundNode = recursiveFind(child, getChildren, findCondition);
        if (foundNode) break;
      }
    } catch (err) {
      _iterator.e(err);
    } finally {
      _iterator.f();
    }
  }
  return foundNode;
}
function recursiveFind ( hierarchicalObject , getChildren , findCondition ) { if ( findCondition ( hierarchicalObject ) ) return hierarchicalObject ; var children = getChildren ( hierarchicalObject ) ; var foundNode = children . find ( findCondition ) ; if ( ! foundNode ) { var _iterator = _createForOfIteratorHelper ( children ) , _step ; try { for ( _iterator . s ( ) ; ! ( _step = _iterator . n ( ) ) . done ; ) { var child = _step . value ; foundNode = recursiveFind ( child , getChildren , findCondition ) ; if ( foundNode ) break ; } } catch ( err ) { _iterator . e ( err ) ; } finally { _iterator . f ( ) ; } } return foundNode ; }
Recursively find a particular object within a hierarchical dataset.
Recursively find a particular object within a hierarchical dataset .