code: public void add(T payload, List<T> parents) {
      // This checks the payload doesn't exist in the graph, and therefore prevents cycles.
      Preconditions.checkState(!contains(payload), "the payload already exists in the DAG");
  
      // construct the new node
      DirectedAcyclicGraphNode<T> newNode = new DirectedAcyclicGraphNode<>(payload);
      mIndex.put(payload, newNode);
  
      if (parents.isEmpty()) {
        // add to root
        mRoots.add(newNode);
      } else {
        // find parent nodes
        for (T parent : parents) {
          Preconditions.checkState(contains(parent),
              "the parent payload " + parent + " does not exist in the DAG");
          DirectedAcyclicGraphNode<T> parentNode = mIndex.get(parent);
          parentNode.addChild(newNode);
          newNode.addParent(parentNode);
        }
      }
    }
docs: Adds a node to the DAG, that takes the given payload and depends on the specified parents.
  
  @param payload the payload
  @param parents the parents of the created node