Change template to reduce redundance
Add extended support for partial paths and correct iteration direction