% collectLeaves(tree): put leaves in cell array
function leaves = collectLeaves(tree) 
if isleaf(tree) %! Base Case
   leaves = {tree.value};
else
   leaves = {};
   for k=1:length(tree.branches)
      foo = collectLeaves(tree.branches{k}); %! Gather leaves for this branch
      leaves = [leaves, foo];
   end
end
