Simplify graph traversal to find requirejs scripts to replace