code: function breadthFirstSearch(obj, handler) {
    var childrenKey = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'children';
    var reverse = arguments[3];
  
    var rootChildren = hp.isArray(obj) ? obj : [obj];
    //
    var stack = rootChildren.map(function (v, i) {
      return { item: v, index: i };
    });
    if (reverse) {
      stack.reverse();
    }
  
    var _loop = function _loop() {
      var _stack$shift = stack.shift(),
          item = _stack$shift.item,
          index = _stack$shift.index,
          parent = _stack$shift.parent;
  
      var r = handler(item, index, parent);
      if (r === false) {
        // stop
        return {
          v: void 0
        };
      } else if (r === 'skip children') {
        return 'continue';
      } else if (r === 'skip siblings') {
        stack = stack.filter(function (v) {
          return v.parent !== parent;
        });
      }
      if (item.children) {
        var _stack;
  
        var children = item.children;
        if (reverse) {
          children = children.slice();
          children.reverse();
        }
        var pushStack = children.map(function (v, i) {
          return { item: v, index: i, parent: item };
        });
        (_stack = stack).push.apply(_stack, _toConsumableArray(pushStack));
      }
    };
  
    while (stack.length) {
      var _ret = _loop();
  
      switch (_ret) {
        case 'continue':
          continue;
  
        default:
          if ((typeof _ret === 'undefined' ? 'undefined' : _typeof(_ret)) === "object") return _ret.v;
      }
    }
  }
docs: 广度优先遍历 Breadth-First-Search