public function formatTree(array $tree)
{
$tree['duration'] = sprintf($this->duration_format, $tree['duration']);
if (isset($tree['percentage'])) {
$tree['percentage'] = sprintf($this->percentage_format, $tree['percentage']);
}
if (isset($tree['periods'])) {
$tree['periods'] = array_map([$this, 'formatTree'], $tree['periods']);
}
return $tree;
}