Find the most suitable parent, that is: the first matching unique/multi inputtemplate
174590
def findparent(self, inputtemplates):
        """"""
        for inputtemplate in inputtemplates:
            if self.unique == inputtemplate.unique:
                return inputtemplate.id
        return None
1246932
function parents (pipe, taskKey) {
  var inputPipesOf = inputPipes.bind(null, pipe)
  var parentTaskIds = []

  function pushParentTaskId (pipe) {
    parentTaskIds.push(pipe[0])
  }

  inputPipesOf(taskKey).forEach(pushParentTaskId)

  return parentTaskIds
}
173127
def _lookup_parent(self, cls):
        """"""
        codeobj = self.parent
        while codeobj is not None and not isinstance(codeobj, cls):
            codeobj = codeobj.parent
        return codeobj
586391
private static Element getFirstChildElement(Node parent) {
		NodeList nodeList = parent.getChildNodes();
		for (int i = 0; i < nodeList.getLength(); i++) {
			Node node = nodeList.item(i);
			if (node instanceof Element) {
				return (Element) node;
			}
		}
		return null;
	}
1049694
def no_missing_parents(data_wrapper):
    '''
    '''
    db = data_wrapper.data_block
    ids = np.setdiff1d(db[:, COLS.P], db[:, COLS.ID])[1:]
    return CheckResult(len(ids) == 0, ids.astype(np.int) + 1)
489363
def get_parent_id(element):
        """"""
        if 'parent' in element.attrib:
            return element.attrib['parent']
        else:
            return element.getparent().attrib[add_ns('id')]
831329
private String getUniqueTemplateName(String name, String ext) {
		if (this.getTreeModel().getTemplate(name) == null) {
			// Its unique
			return name;
		}
		// Its not unique, add a suitable index...
		String stub = name.substring(0, name.length() - ext.length() - 1);
		int index = 1;
		do {
			index++;
			name = stub + "(" + index + ")." + ext;
		}
		while (this.getTreeModel().getTemplate(name) != null);
		
		return name;
	}
1138166
def pkeys(self,parent,field):
    ""
    template=[(parent[k] if k is not None else None) for k in self.pkey]
    inull=template.index(None)
    def mk(x):
      "helper for constructing pkey tuples in a list comp"
      template[inull]=x
      return tuple(template)
    val=parent[field]
    if self.getter is not None: return map(mk,self.getter(val))
    elif isinstance(val,VDList): return map(mk,val.generate())
    else: raise NotImplementedError(type(val))
1307052
def find_replacement(self):
        

        if self.right:
            child, parent = self.right.extreme_child(min, self.axis)
        else:
            child, parent = self.left.extreme_child(max, self.axis)

        return (child, parent if parent is not None else self)
520361
function getParent(type, id, parentType, root) {
		return _client.retrieve({
			type: type,
			id: id,
			properties: ['parent']
		})
		.then(function(obj) {
			
			if (obj.length > 0) {
				
				obj  = _.first(obj);
				type = _.get(obj, 'parent.type');
				id   = _.get(obj, 'parent.id');
				
				// if there is no parent type or id, the parent could not be found, throw an error
				if (!type || !id) {
					throw {
						errorCode: 404,
						message: 'could not find parent type'
					};
				}
				
				// if the parent is a match
				if (type === parentType) {
					
					// if a root search, keep looking for parent objects of the same type
					if (root === true) {
						return _client.retrieve({
							type: type,
							id: id,
							properties: ['parent']
						})
						.then(function(parent) {
							if (_.get(parent, 'parent.type') === parentType) {
								return getParent(type, id, parentType, root);
							}
							return {
								id: id,
								type: parentType
							};
						});
					}
					return {
						id: id,
						type: parentType
					};
				}
				
				return getParent(type, id, parentType, root);
			}
			
			throw {
				errorCode: 404,
				message: 'Object not found'
			};
		});
	}
734285
function closest (el, sel) {
  if (!el) return
  if (matches(el, sel)) {
    return el
  } else {
    return closest(el.parentNode, sel)
  }
}
742128
def firstChild(self):
        '''
            
        '''
        blocks = object.__getattribute__(self, 'blocks')
        # First block is empty string for indent, but don't hardcode incase that changes
        if blocks[0] == '':
           firstIdx = 1
        else:
           firstIdx = 0

        if len(blocks) == firstIdx:
            # No first child
            return None

        return blocks[1]
1146202
function checkIfStyleCanBeChildOf( def, currentParent, elementName, isUnknownElement ) {
		return currentParent &&
			( ( currentParent.getDtd() || CKEDITOR.dtd.span )[ elementName ] || isUnknownElement ) &&
			( !def.parentRule || def.parentRule( currentParent ) );
	}
89450
def inputtemplate(self,template_id):
        """"""
        for profile in self.profiles:
            for inputtemplate in profile.input:
                if inputtemplate.id == template_id:
                    return inputtemplate
        raise Exception("No such input template: " + repr(template_id))
816347
def find_parents(name, parents=None):
    
    template = loader.get_template(name)
    source, origin = find_template_source(name)
    if parents is None:
        parents = []
    else:
        parents.append({'name': name, 'file': origin})
    for node in template:
        if isinstance(node, ExtendsNode):
            parent_name = node.parent_name.token.strip('"')
            return find_parents(parent_name, parents)
    return parents
73414
def first(self):
        
        self.reset()
        value = next(self, None)
        if value is None:
            raise ConstraintViolation("{} did not find any results.".format(self.mode.capitalize()))
        return value
1251255
def get_parent(self):
        """"""
        return None if self.zoom == 0 else self.tile_pyramid.tile(
            self.zoom - 1, self.row // 2, self.col // 2
        )