code: private void build() {
      this.startNodes = new ArrayList<>();
      this.endNodes = new ArrayList<>();
      this.parentChildMap = new HashMap<>();
      for (DagNode node : this.nodes) {
        //If a Node has no parent Node, add it to the list of start Nodes
        if (node.getParentNodes() == null) {
          this.startNodes.add(node);
        } else {
          List<DagNode> parentNodeList = node.getParentNodes();
          for (DagNode parentNode : parentNodeList) {
            if (parentChildMap.containsKey(parentNode)) {
              parentChildMap.get(parentNode).add(node);
            } else {
              parentChildMap.put(parentNode, Lists.newArrayList(node));
            }
          }
        }
      }
      //Iterate over all the Nodes and add a Node to the list of endNodes if it is not present in the parentChildMap
      for (DagNode node : this.nodes) {
        if (!parentChildMap.containsKey(node)) {
          this.endNodes.add(node);
        }
      }
    }
docs: Constructs the dag from the Node list.