human
Complete this python program:
def TreeRepr(tree, depth=0):
assistant
#Here is the Python code you requested.

    """Generate a string representation of an ANTLR parse tree for debugging.
    """
    def _NodeRepr(node):
        text = str(node.getType())
        if node.getText():
            text = ('%s:    %s' % (text, node.getText()))
        return text
    children = ''
    if tree.children:
        children = ('\n' + '\n'.join([TreeRepr(child, depth=(depth + 1)) for child in tree.children if child]))
    return (((depth * '        ') + _NodeRepr(tree)) + children)