code: function(element, iteratee, opt) {
  
          opt = opt || {};
          var visited = {};
          var distance = {};
          var queue = [];
  
          queue.push(element);
          distance[element.id] = 0;
  
          while (queue.length > 0) {
              var next = queue.shift();
              if (!visited[next.id]) {
                  visited[next.id] = true;
                  if (iteratee(next, distance[next.id]) === false) return;
                  this.getNeighbors(next, opt).forEach(function(neighbor) {
                      distance[neighbor.id] = distance[next.id] + 1;
                      queue.push(neighbor);
                  });
              }
          }
      }
docs: Breadth-first search. If `opt.deep` is `true`, take into account embedded elements too. If `opt.inbound` is `true`, reverse the search direction (it's like reversing all the link directions). `iteratee` is a function of the form `function(element, distance) {}`. where `element` is the currently visited element and `distance` is the distance of that element from the root `element` passed the `bfs()`, i.e. the element we started the search from. Note that the `distance` is not the shortest or longest distance, it is simply the number of levels crossed till we visited the `element` for the first time. It is especially useful for tree graphs. If `iteratee` explicitely returns `false`, the searching stops.