Get a value from a dictionary under N keys, represented as str("key1.key2...key{n}")

def _get_value_from_json(self, dict_path, metrics_json):
        """
        Get a value from a dictionary under N keys, represented as str("key1.key2...key{n}")
        """
        for key in dict_path.split('.'):
            if key in metrics_json:
                metrics_json = metrics_json.get(key)
            else:
                return None
        return metrics_json