export default class BasicNode {
  constructor(id, graph) {
    this.id = id;
    this.graph = graph;
  }

  children(oneLevel = true) {
    return this.graph.children(this.id, oneLevel)
  }

  directParents() {
    return this.graph.directParents(this.id)
  }

  get maxDistanceFromRoot() {
    if (_.isUndefined(this._maxDistanceFromRoot)) {
      this._maxDistanceFromRoot = this._calculateMaxDistanceFromRoot([this])
    }
    return this._maxDistanceFromRoot
  }

  _calculateMaxDistanceFromRoot(nodesToIgnore): integer {
    if (_.isUndefined(this._maxDistanceFromRoot)) {
      const ancestors = _.uniq(_.flatten(this.directParents())).filter(node => (!_.some(nodesToIgnore, s => s.id === node.id)))
      const distances = ancestors.map(n => n._calculateMaxDistanceFromRoot(nodesToIgnore.concat([this])))

      this._maxDistanceFromRoot = distances.length > 0 ? Math.max(...distances) + 1 : 0
    }
    return this._maxDistanceFromRoot
  }
}

@@ -584,24 +584,22 @@
   const 
-ancestor
+parent
 s = _.un
@@ -637,24 +637,43 @@
 ()))
-.filter(
+%0A      if (_.some(parents, 
 node =%3E 
 (!_.
@@ -668,17 +668,16 @@
 node =%3E 
-(
 !_.some(
@@ -715,16 +715,50 @@
 de.id)))
+%7B%0A        return -Infinity%0A      %7D
 %0A      c
@@ -778,16 +778,14 @@
 s = 
-ancestor
+parent
 s.ma

Set distance to root to infinity in graph work.