Applying material settings from external file ruins my code sequence

Hello, this is going to be tough 'cause I came here with issues I can’t resolve by myself. In order to train my skils I’m creating an import script (3ds max 2009 32bit) for folder of FBX format. Everything worked the way I can call ‘RIGHT’ till I’d tried to add a function to apply material setting from external file. Settings are not applying and ruins the whole sequence allowing to import FBX as is. What my script do by default:

  1. imports FBX file from folder (by settings from external file)
  2. places all objects from given FBX into corresponded layer by LOD suffix
  3. renames every object by the name of its material name (which is always starts with ‘assets/textures/mtl_’) + LOD index
  4. removes all unused bones (this is not mine but works)
  5. applies material settings to each object - this is where I have problem
  6. adds an object into corresponded layer (by LOD index)

p.s.: there’s 2 redundant events (unbend, specLvl) ignore them
p.s.2: every mesh in FBX have material name called ‘assets/textures/’ whereis the external filename I’m trying to load + .mtl extension
here’s link to example files and script: https://drive.google.com/open?id=1OeMnYex51wYfrsHtF_5L70Taa80I2PJ8