class TagDaoHelper {

    public List<TagEntity> getTagChildrenEntities(TagEntity parentTagEntity)
    {
        // Get the maximum allowed tag nesting level.
        Integer maxAllowedTagNesting = configurationHelper.getProperty(ConfigurationValue.MAX_ALLOWED_TAG_NESTING, Integer.class);

        // Build a list of the specified tag along with all its children tags down the hierarchy up to maximum allowed tag nesting level.
        List<TagEntity> parentTagEntities = new ArrayList<>();
        parentTagEntities.add(parentTagEntity);
        List<TagEntity> tagEntities = new ArrayList<>();
        for (int level = 0; !parentTagEntities.isEmpty() && level < maxAllowedTagNesting; level++)
        {
            parentTagEntities = tagDao.getChildrenTags(parentTagEntities);
            tagEntities.addAll(parentTagEntities);
        }

        return tagEntities;
    }

}