def traverse(d, metric_name=''):
            """
            Traverse the given nested dict using depth-first search.

            If a value is reached it will be published with a metric name
            consisting of the hierarchically concatenated keys
            of its branch.
            """
            for key, value in d.iteritems():
                if isinstance(value, dict):
                    if metric_name == '':
                        metric_name_next = key
                    else:
                        metric_name_next = metric_name + '.' + key
                    traverse(value, metric_name_next)
                else:
                    metric_name_finished = metric_name + '.' + key
                    self.publish_gauge(
                        name=metric_name_finished,
                        value=value,
                        precision=1
                    )

            Traverse the given nested dict using depth-first search.

            If a value is reached it will be published with a metric name
            consisting of the hierarchically concatenated keys
            of its branch.
            
src/collectors/mdstat/mdstat.py