code: public Set<DagNode<T>> getDependencyNodes(Set<DagNode<T>> forkNodes) {
      Set<DagNode<T>> dependencyNodes = new HashSet<>();
      for (DagNode<T> endNode : endNodes) {
        if (!forkNodes.contains(endNode)) {
          dependencyNodes.add(endNode);
        }
      }
  
      //Get all ancestors of non-forkable nodes
      Set<DagNode<T>> ancestorNodes = this.getAncestorNodes(dependencyNodes);
  
      //Add ancestors of the parents of forkable nodes
      for (DagNode<T> dagNode: forkNodes) {
        List<DagNode<T>> parentNodes = this.getParents(dagNode);
        ancestorNodes.addAll(this.getAncestorNodes(Sets.newHashSet(parentNodes)));
      }
  
      for (DagNode<T> dagNode: forkNodes) {
        List<DagNode<T>> parentNodes = this.getParents(dagNode);
        for (DagNode<T> parentNode : parentNodes) {
          //Add parent node of a forkable node as a dependency, only if it is not already an ancestor of another
          // dependency.
          if (!ancestorNodes.contains(parentNode)) {
            dependencyNodes.add(parentNode);
          }
        }
      }
      return dependencyNodes;
    }
docs: This method computes a set of {@link DagNode}s which are the dependency nodes for concatenating this {@link Dag}
  with any other {@link Dag}. The set of dependency nodes is the union of:
  <p><ul>
  <li> The endNodes of this dag which are not forkable, and </li>
  <li> The parents of forkable nodes, such that no parent is an ancestor of another parent.</li>
  </ul></p>
  
  @param forkNodes set of nodes of this {@link Dag} which are forkable
  @return set of dependency nodes of this dag for concatenation with any other dag.