now we are discussing the case when for selected node all rows inside details grid have empty values for the some column (like size on screenshot). Is it correct to hide such empty columns or not?
The reason the Size column is shown in your examples is because in some cases, there will be items with sizes. A user might drop a file into the folder, which would have a size. If the Size column were hidden sometimes, the user might wonder, "Is this because there are no items with sizes, or because the system has a bug?"
If there will never, ever be a value in the Size column (for example: a user preference to not show size) then hiding it would make sense.
What does the user gain from it being hidden? And what does he or she lose by hiding it?
It's a compromise of more space or cleaner look vs. potentially confusing the user with inconsistent columns across the application.
Maintain Consistency and Adhere to Standards (Usability Heuristic #4)
Users should not have to wonder whether different words, situations, or actions mean the same thing. Follow platform and industry conventions.
One of the main usability guidelines tells us to keep our products and designs as consistent as possible, internally as well as externally. Meaning that inside your application all UI should follow the same rules and not change drastically from screen to screen. Looking outside, it should follow standards built by other applications, which your users have used and formed their expectations upon.
Jakob's Law of Internet User Experience
Users spend most of their time on other sites. This means that users prefer your site to work the same way as all the other sites they already know. Design for patterns for which users are accustomed.
Pointing to the same argument with this quote, users have expectations based on previous experience with software. So make sure they don't get confused by things that you do differently.
TL;DR: All in all I would place the point of consistency far above cleaner looks, especially if it's a business software.