avutil/tree: fix memleaks