Hello,
You can take advantage of the Text/XML transformation types, where you can use context macros, so you can add similar statement to it:
{%Documents[CurrentDocument.NodeAliasPath+"/Directory"].Children.Count%}
This return a number of children of the Directory subfolder of current document/product and if this value is greater than 0, then you can show the item.
Otherwise (with the ASCX transformation), you would need to write your own
transformation function or resolve macros by using API.
Best regards,
Jan Hermann