Simplify this logic and avoid creation of lots of temp arrays like this:

```
// recursive function which adds direct ancestor pseudo nodes to nodes array
var addPseudoNodes = function(node) {
  if (node == null || !node.pseudo) return;
  nodes.push(node);
  node.parents.forEach(addPseudoNodes);
};

// initial nodes are not pseudo, but parents may be...
nodes.slice(0).forEach(function(node) { node.parents.forEach(addPseudoNode); });
```