Check if children is empty before doing a foreach