@throws_when_stopped
    def ensure_path(self, path):
        if not path.startswith("/"):
            raise RuntimeError("Path has to be absolute.")

        parent_node = None
        first_non_existing_node = True
        for node_name in self._get_node_names(path):
            if parent_node is None:
                # The root node, name should be empty string
                assert not node_name
                parent_node = MockKazooClient.ZK_ROOT_NODE
            else:
                tmp_parent_node = parent_node.get_child(node_name)
                if tmp_parent_node is None:
                    parent_node.add_child(node_name, "")
                    tmp_parent_node = parent_node.get_child(node_name)
                    if first_non_existing_node:
                        self._notify_children_watches(str(parent_node))
                        first_non_existing_node = False
                parent_node = tmp_parent_node
Ensure the existence of the path; if not, create the nodes.
dataset/ETHPy150Open pinterest/kingpin/kingpin/tests/kazoo_utils/mock_kazoo_client.py/MockKazooClient.ensure_path