Check that the element's allowed parents are limited to the specified element types.
11211
void assertParent(Collection<Class<? extends Element>> permittedParents) throws InvalidInputException {
    if (!permittedParents.contains(this.getParent().getClass())) {
      throw new InvalidInputException("Element \"" + this.getMessageMLTag() + "\" is not allowed as a child of \""
          + this.getParent().getMessageMLTag() + "\"");
    }
  }
242038
public static boolean canAcceptParent(Class<? extends ElementBase> childClass,
                                          Class<? extends ElementBase> parentClass) {
        return allowedParentClasses.isRelated(childClass, parentClass);
    }
1064331
def iselect(self, tag, limit=0):
        """"""

        for el in CSSMatch(self.selectors, tag, self.namespaces, self.flags).select(limit):
            yield el
1170813
function checkParentsProperty(elem, property, value) {
    while (elem = elem.offsetParent) {
        if (getCss(elem, property) === value) {
            return true;
        }
    }
    return false;
}
767756
def select_by_selector(self, selector):
    """"""
    option = find_element_by_jquery(world.browser, selector)
    selectors = find_parents_by_jquery(world.browser, selector)
    if not selectors:
        raise AssertionError("No parent element found for the option.")
    selector = selectors[0]
    selector.click()
    sleep(0.3)
    option.click()
    if not option.is_selected():
        raise AssertionError(
            "Option should have become selected after clicking it.")
476200
function validate_child_style_class_types(parent_node_names, names)
{
	for (let parent of parent_node_names)
	{
		// if it's a pseudoclass, it can't contain any style classes
		if (is_pseudo_class(parent) && not_empty(names))
		{
			throw new Error(`A style class declaration "${names[0]}" found inside a pseudoclass "${parent}". Pseudoclasses (:hover, etc) can't contain child style classes.`)
		}

		// if it's a media query style class, it must contain only pseudoclasses
		if (is_media_query(parent))
		{
			const non_pseudoclass = names.filter(x => !is_pseudo_class(x))[0]

			if (non_pseudoclass)
			{
				throw new Error(`A non-pseudoclass "${non_pseudoclass}" found inside a media query style class "${parent}". Media query style classes can only contain pseudoclasses (:hover, etc).`)
			}
		}
		
		// if it's a keyframes style class, it must contain only keyframe selectors
		if (is_keyframes(parent)) {
			const non_keyframe_selector = names.filter(x => !is_keyframe_selector(x))[0]

			if (non_keyframe_selector) 
			{
				throw new Error(`A non-keyframe-selector "${non_keyframe_selector}" found inside a keyframes style class "${parent}". Keyframes style classes can only contain keyframe selectors (from, 100%, etc).`);
			}
		}
	}
}
1286593
def _allowAnotherAt(cls, parent):
        """"""
        site = parent.get_site()
        if site is None:
            return False
        return not cls.peers().descendant_of(site.root_page).exists()
858278
def find_embedded_parent(self, element):
        
        result = None
        for t in self.types:
            if (element.start > self.types[t].start and
                element.end < self.types[t].end):
                result = self.types[t]
                break
        else:
            for iexec in self.executables:
                if (element.start > self.executables[iexec].start and
                    element.end < self.executables[iexec].end):
                    result = self.executables[iexec]
                    break

        return result
897748
function(type) {
			var result = this.spirit.element.parentNode;
			if (type) {
				var spirit = result.spirit;
				if (spirit && spirit instanceof type) {
					result = spirit;
				} else {
					result = null;
				}
			}
			return result;
		}
1305061
public boolean canAcceptParent(Class<? extends ElementBase> clazz) {
        if (!canAcceptParent(getClass(), clazz)) {
            rejectReason = getDisplayName() + " does not accept " + clazz.getSimpleName() + " as a parent.";
        } else {
            rejectReason = null;
        }
        
        return rejectReason == null;
    }
1146202
function checkIfStyleCanBeChildOf( def, currentParent, elementName, isUnknownElement ) {
		return currentParent &&
			( ( currentParent.getDtd() || CKEDITOR.dtd.span )[ elementName ] || isUnknownElement ) &&
			( !def.parentRule || def.parentRule( currentParent ) );
	}
197940
private void checkForDuplicateAttributes(ParentSoyNode<StandaloneNode> parentNode) {
    DuplicateAttributesVisitor visitor = new DuplicateAttributesVisitor();
    List<StandaloneNode> children = parentNode.getChildren();
    if (parentNode instanceof HtmlTagNode) {
      // the first child is the tag name, which isn't interesting, so skip it
      children = children.subList(1, children.size());
    }
    for (SoyNode child : children) {
      visitor.exec(child);
    }
  }
1045791
void assertContentModel(Collection<Class<? extends Element>> permittedChildren) throws InvalidInputException {
    for (Element child : this.getChildren()) {
      if (!permittedChildren.contains(child.getClass())) {

        //Permit whitespace
        if (child instanceof TextNode && StringUtils.isBlank(((TextNode) child).getText())) {
          continue;
        }

        throw new InvalidInputException("Element \"" + child.getMessageMLTag() + "\" is not allowed in \""
            + this.getMessageMLTag() + "\"");
      }
    }
  }
1234756
@Override
    protected boolean isAcceptable(Element element) {
        if (element.getKind() == ElementKind.METHOD) {
            Set<Modifier> modifiers = element.getModifiers();
            return modifiers.contains(Modifier.PUBLIC) && !modifiers.contains(Modifier.FINAL) && !modifiers.contains(Modifier.STATIC);
        } else {
            return false;
        }
    }
123220
def element_type(self, type_):
        """"""
        return self.__find_xxx_type(
            type_,
            self.element_type_index,
            self.element_type_typedef,
            'container_element_type')
834221
private boolean checkParents( boolean exclusive ) {
        if (path.equals("/")) {
            return true;
        }
        if (owner == null) {
            // no owner, checking parents
            return parent != null && parent.checkParents(exclusive);
        }
        // there already is a owner
        return !(this.exclusive || exclusive) && parent.checkParents(exclusive);
    }
402231
private boolean allTypesExist(Collection<? extends Element> elements) {
    for (Element element : elements) {
      if (element.asType().getKind() == TypeKind.ERROR) {
        return false;
      }
    }
    return true;
  }