[Tree] Fix getting root nodes for materialized path

If you change TreePath: path_stats_with_separator or path_ends_with_separator, getRootNodes() stop working.

This patch will fix this problem.