def render_tree(root, child_func, prune=0, margin=[0], visited=None):
    rname = str(root)
    if visited is None:
        visited = {}
    children = child_func(root)
    retval = ""
    for pipe in margin[:-1]:
        if pipe:
            retval = retval + "| "
        else:
            retval = retval + "  "
    if rname in visited:
        return retval + "+-[" + rname + "]\n"
    retval = retval + "+-" + rname + "\n"
    if not prune:
        visited = copy.copy(visited)
    visited[rname] = 1
    for i in range(len(children)):
        margin.append(i < len(children)-1)
        retval = retval + render_tree(children[i], child_func, prune, margin, visited)
        margin.pop()
    return retval