How to use animation from different skeleton structure ?

I want to use some animations which belongs to different skeleton structure( both are humanoid). The anim I want to use has a bit different structure and has IK leg handler. Additionally, has some extra bones which will not affect animation play other bones are same. If I am not wrong I got error message and character became completely damaged (IDK why).

Is there a proper way to do that ?

Thanks for any explanation. I may try it in a empty project.