code: public List<UninstallAsset> determineOrder(List<UninstallAsset> list) {
          Map<String, Integer> visited = new HashMap<String, Integer>();
          Map<String, UninstallAsset> assetsMap = new HashMap<String, UninstallAsset>();
          for (UninstallAsset ua : list) {
              assetsMap.put(ua.getProvisioningFeatureDefinition().getSymbolicName(), ua);
          }
          AtomicInteger order = new AtomicInteger(list.size()); // Doesn't really need to be atomic, just using it for an int holder object
          for (UninstallAsset ua : list) {
              if (!!!visited.containsKey(ua.getProvisioningFeatureDefinition().getSymbolicName())) {
                  DFS(ua, visited, assetsMap, order);
              }
          }
  
          Collections.sort(list, new FeatureDependencyComparator(visited));
          return list;
      }
docs: Determine the order of the features according to their dependency
  Use DFS approach to solve the Topological Sort problem.
  visited map will be used to store the order of the asset
  the DFS will search for all the assets without required features, and work its way backward to find the order.
  
  @param list list of the features
  @return the sorted feature list according to the feature dependency