private void buildRootList(final Collection c, final boolean reverse) {
		final HashSet visited = new HashSet(nodes.size() * 2);
		final ArrayList stack = new ArrayList();

		final Iterator iter = nodes.values().iterator();

		while (iter.hasNext()) {
			final GraphNode node = (GraphNode) iter.next();

			if (!visited.contains(node)) {
				visited.add(node);
				stack.add(node);

				while (!stack.isEmpty()) {
					final GraphNode v = (GraphNode) stack
							.remove(stack.size() - 1);
					boolean pushed = false;

					final Iterator preds = reverse ? v.succs.iterator()
							: v.preds.iterator();

					while (preds.hasNext()) {
						final GraphNode w = (GraphNode) preds.next();

						if (!visited.contains(w)) {
							visited.add(w);
							stack.add(w);
							pushed = true;
						}
					}

					if (!pushed) {
						c.add(v);
					}
				}
			}
		}
	}