Detect if an entity isn't moving and so much time passed.

How to detect if an entity has not moved since 10 seconds? I want to make it such that the entity which is been stuck and unable to path find further, a tnt will spawn and make a way for that entity to move again.
Continue to help post