Improved path_matching to handle nested matching currentry