Return None if not found.
421655
def _get_chain_by_sid(sid):
    """"""
    try:
        return d1_gmn.app.models.Chain.objects.get(sid__did=sid)
    except d1_gmn.app.models.Chain.DoesNotExist:
        pass
674698
def searchbyno(self, no):
        
        pattern = re.compile(str(no))
        result = {}
        for i in self.__allstockno:
            query = re.search(pattern, str(i))
            if query:
                query.group()
                result[i] = self.__allstockno[i]
        return result
572207
def find_object(self, key, layers):
        ''''''
        state = self.state

        if layers is None or layers == '':
            layers = state.layers.keys()
        for layer in layers:
            if key in state.layers[layer]:
                return state.layers[layer][key]
        return None
919671
def find(self, path):
        """"""
        path = path.split('.')
        node = self
        while node._parent:
            node = node._parent
        for name in path:
            node = node._tree.get(name, None)
            if node is None or type(node) is float:
                return None
        return node
190446
def select(self):
        
        err = self._oasis_obj.error
        if np.allclose(err, 0):
            return None
        nsel = self._check_nsel()
        if nsel is None:
            return None
        return self._select(nsel, err)
554024
def find_one(self, *args, **kwargs):
        
        doc = self._collection_with_options(kwargs).find_one(*args, **kwargs)
        if doc is None:
            return None

        return doc
777435
def _visit_or_none(node, attr, visitor, parent, visit="visit", **kws):
    
    value = getattr(node, attr, None)
    if value:
        return getattr(visitor, visit)(value, parent, **kws)

    return None
1219441
def _is_excluded(self, path, dir_only):
        """"""

        return self.npatterns and self._match_excluded(path, self.npatterns)
1057281
def get(self, term, default=None):
        """"""
        v =  self.find_first(term)

        if not v:
            return default
        else:
            return v
385897
def search_one(self, keyword, arg=None, children=None):
        
        if children is None:
            children = self.substmts
        for ch in children:
            if ch.keyword == keyword and (arg is None or ch.arg == arg):
                return ch
        return None
472803
def find_parameter(self, name):
        """"""
        name = self.normalize_name(name)
        arg = self.args.get(name)
        return None if arg is None else arg.parameter
792243
def ensure_ndarray_or_None(A, shape=None, uniform=None, ndim=None, size=None, dtype=None, kind=None):
     """
    if A is not None:
        return ensure_ndarray(A, shape=shape, uniform=uniform, ndim=ndim, size=size, dtype=dtype, kind=kind)
    else:
        return None
1225586
def nonver_name(self):
        """"""
        nv = self.as_version(None)
        if not nv:
            import re
            nv = re.sub(r'-[^-]+$', '', self.name)

        return nv
1220129
def get_one_optional(self, locator):
        
        try:
            components = self.find(locator, False)
            return components[0] if len(components) > 0 else None
        except Exception as ex:
            return None
736917
def item(self, index: int) -> Optional[Attr]:
        """"""
        if 0 <= index < len(self):
            return self._dict[tuple(self._dict.keys())[index]]
        return None
537986
def get(self, key, default=None):
        """"""
        if type(self.attrs) == dict:
            return self.attrs.get(key, default)
        else:
            raise NotImplementedError
1231134
def search(self, value):
        """"""
        if self.payload == value:
            return self
        else:
            if value <= self.payload:
                if self.left:
                    return self.left.search(value)
            else:
                if self.right:
                    return self.right.search(value)
        return None