passes/hierarchy: Reduce code duplication in expand_module
passes/hierarchy: Reduce code duplication in expand_module

This also makes it easier to add new file extensions support.

Signed-off-by: Sergi Granell <267da16bc43a248e339612f39680c45ec4626142@gmail.com>

antmicro/yosys,antmicro/yosys,antmicro/yosys,SymbiFlow/yosys,SymbiFlow/yosys,cliffordwolf/yosys,cliffordwolf/yosys,YosysHQ/yosys,YosysHQ/yosys,cliffordwolf/yosys,cliffordwolf/yosys,YosysHQ/yosys,cliffordwolf/yosys,SymbiFlow/yosys,YosysHQ/yosys,SymbiFlow/yosys,SymbiFlow/yosys,antmicro/yosys,cliffordwolf/yosys,cliffordwolf/yosys,antmicro/yosys,cliffordwolf/yosys,SymbiFlow/yosys,YosysHQ/yosys,cliffordwolf/yosys,SymbiFlow/yosys,antmicro/yosys,SymbiFlow/yosys,YosysHQ/yosys,antmicro/yosys,antmicro/yosys,YosysHQ/yosys,YosysHQ/yosys