I'm a bit confused with func_modules_transitive_closure function, especially with its conditions part. Previous experience has shown that it would be better not to write the exact copy of the code, but do what is supposed to be done. Could you, please, tell what you expect in this section?