Refactored directory iteration for treeview to Laravel style