function D = dataFromLayer(tree, layer, D)
if layer==0
    D = cat(2, D, tree.data);
    return;
end
children = getchildren(tree);
for i=1:length(children)
    D = dataFromLayer(children{i}, layer-1, D);
end
return;