Dave Bauer's code looks like something I'll want to go with, but for the sake of learning, let's figure out what's wrong with my code.
get_tree $children [lindex $elements $i] $parent $level
gives me this error:
can't read "parent": variable is array
Your suggestion makes sense to me and I've tried it before. Right now I'm passing one element and I guess the question comes down to how I pass the whole array (of course likewise with the recursive call to get_tree).