private void extendTransitiveDependency() {
    for (Map.Entry<RoleCommandPair, Set<RoleCommandPair>> roleCommandPairSetEntry : dependencies.entrySet()) {
      HashSet<RoleCommandPair> visited = new HashSet<>();
      HashSet<RoleCommandPair> transitiveDependencies = new HashSet<>();
      for (RoleCommandPair directlyBlockedOn : dependencies.get(roleCommandPairSetEntry.getKey())) {
        visited.add(directlyBlockedOn);
        identifyTransitiveDependencies(directlyBlockedOn, visited, transitiveDependencies);
      }
      if (transitiveDependencies.size() > 0) {
        dependencies.get(roleCommandPairSetEntry.getKey()).addAll(transitiveDependencies);
      }
    }
  }
Adds transitive dependencies to each node.
A => B and B => C implies A => B,C and B => C
ambari-server/src/main/java/org/apache/ambari/server/metadata/RoleCommandOrder.java