<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def template_to_dict_iter_debug(elm):
 """ Print expanded element on stdout for debugging """

    if elm.text is not None:
        print("    <%s>%s</%s>" % (elm.tag, elm.text, elm.tag), end='')
        if elm.tail is not None:
            print(elm.tail)
        else:
            print()
    else:
        if elm.tail is not None:
            print("    <%s>%s" % (elm.tag, elm.tail))
        else:
            print("    <%s>" % elm.tag)