code: protected void addDependenciesRecursively(Namespace namespace, List<Namespace> namespaceList, String dependencyId, List<String> extendedDependencies) throws XmlException {
          if(extendedDependencies.contains(dependencyId)) {
              return;
          }
          if(namespace.getId().equals(dependencyId)) {
              throw new XmlException("Circular dependency found in " + namespace.getId());
          }
  
          Namespace dependency = find(namespaceList, dependencyId);
          extendedDependencies.add(dependency.getId());
          for(String indirectDependencyId: dependency.getDirectDependencyIds()) {
              addDependenciesRecursively(namespace, namespaceList, indirectDependencyId, extendedDependencies);
          }
      }
docs: Adds dependencyId, and all of it's depdencies recursively using namespaceList, to extendedDependencies for namespace.
  @throws XmlException