

proc refresh {items params} {
	set paramsChild $params
	set padding 25
	dict incr paramsChild level 
	dict incr paramsChild y $padding
	dict incr paramsChild x $padding
	foreach child $items {
		set resultChild [refresh $child $paramsChild]
		dict incr paramsChild y [expr { $padding + [dict get $resultChild h] }]
		dict with params {
			if { $w + $x < [dict get $resultChild w] + [dict get $resultChild x] } {
				set w [expr {[dict get $resultChild w] + [dict get $resultChild x] - $x}]
			}
			if { $h + $y < [dict get $resultChild h] + [dict get $resultChild y] } {
				set h [expr {[dict get $resultChild h] + [dict get $resultChild y] - $y}]
			}
			incr h $padding
		}
	}
	dict incr params w $padding

	return $params
}

set a {}
set b [list $a]
set c [list $b $b]

set p [refresh $c {level 0 x 0 y 0 w 10 h 20}]
puts $p



