Set<MavenArtifact> processed = new HashSet<MavenArtifact>();
// flatten the tree while taking care of endless recursions
LinkedList<MavenArtifactNode> nodes = new LinkedList<MavenArtifactNode>(project.getDependencyTree());
while (!nodes.isEmpty()) {
MavenArtifactNode node = nodes.pop();
MavenArtifact artifact = node.getArtifact();
if (!processed.contains(artifact)) {
processed.add(artifact);
nodes.addAll(node.getDependencies());
}
}
dependencies = processed;
}
else {