'Recursively scans UI tree for ``bind`` properties, and creates bindings.'

def __autodiscover(self, object=None, ui=None):

    if ((object is None) and (ui is None)):
        self.bindings = []
    if (ui is None):
        ui = self.ui
    if (object is None):
        object = self.object
    bindables = ui.nearest((lambda x: is_bound(x)), exclude=(lambda x: ((x.parent != ui) and (x != ui) and (('{bind}context' in x.parent.properties) or x.parent.typeid.startswith('bind:')))))
    for bindable in bindables:
        if bindable.typeid.startswith('bind:'):
            k = bindable.bind
            if (k and Binding.applicable(object, k)):
                self.add(bindable.binding(object, k, bindable))
            continue
        for prop in bindable.properties:
            if ((not prop.startswith('{bind')) and (prop != 'bind')):
                continue
            k = bindable.properties[prop]
            if (prop == '{binder}context'):
                if ((bindable is not ui) and k):
                    if Binding.applicable(object, k):
                        self.__autodiscover(Binding.extract(object, k), bindable)
            if (prop.startswith('{bind}') or (prop == 'bind')):
                propname = (None if (prop == 'bind') else prop.split('}')[1])
                if (k and Binding.applicable(object, k)):
                    self.add(PropertyBinding(object, k, bindable, propname))
    return self
