

def add(self, child, z=0, name=None):
    'Adds a child and if it becomes part of the active scene, it calls\n        its :meth:`on_enter` method.\n\n        Arguments:\n            child (CocosNode):\n                object to be added\n            z (Optional[float]):\n                the child z index. Defaults to 0.\n            name (Optional[str]):\n                Name of the child. Defaults to ``None``\n\n        Returns:\n            CocosNode: self\n\n        '
    if name:
        if (name in self.children_names):
            raise Exception(('Name already exists: %s' % name))
        self.children_names[name] = child
    child.parent = self
    elem = (z, child)
    lo = 0
    hi = len(self.children)
    a = self.children
    while (lo < hi):
        mid = ((lo + hi) // 2)
        if (z < a[lo][0]):
            hi = mid
        else:
            lo = (mid + 1)
    self.children.insert(lo, elem)
    if self.is_running:
        child.on_enter()
    return self

dataset/ETHPy150Open los-cocos/cocos/cocos/cocosnode.py CocosNode.add/VarMisuse@119/281 `mid`->`lo`