topological sort. silence harmless static analyzer warnings