We check if the parent if of the expected class, hoping that if it is then we can avoid wrapping this condition in
parentheses and still maintain the same logic.

@return {@code true} if wrapping is needed, {@code false} otherwise
177443
private boolean parentIsNotOfClass(BaseCondition condition, Class<? extends BooleanCondition> expectedParentClass) {
      BaseCondition parent = condition.getParent();
      return parent != null && parent.getClass() != expectedParentClass;
   }
337044
function isParenthesisedTwice(node) {
            const previousToken = sourceCode.getTokenBefore(node, 1),
                nextToken = sourceCode.getTokenAfter(node, 1);

            return isParenthesised(node) && previousToken && nextToken &&
                astUtils.isOpeningParenToken(previousToken) && previousToken.range[1] <= node.range[0] &&
                astUtils.isClosingParenToken(nextToken) && nextToken.range[0] >= node.range[1];
        }
827774
public static boolean parentContainsOnlyLeaves(ParentNode parentNode) {
        for (Node child : parentNode.children()) {
            if (!isLeaf(child)) return false;
        }
        return true;
    }
627078
public boolean isPreTerminal() {
        if (children == null && label != null && !label.equals("TOP"))
            children = new ArrayList<>();
        if (children != null && children.size() == 1) {
            Tree child = children.get(0);
            return child != null && child.isLeaf();
        }
        return false;
    }
1009536
function is(test, node, index, parent, context) {
  var hasParent = parent !== null && parent !== undefined
  var hasIndex = index !== null && index !== undefined
  var check = convert(test)

  if (
    hasIndex &&
    (typeof index !== 'number' || index < 0 || index === Infinity)
  ) {
    throw new Error('Expected positive finite index or child node')
  }

  if (hasParent && (!is(null, parent) || !parent.children)) {
    throw new Error('Expected parent node')
  }

  if (!node || !node.type || typeof node.type !== 'string') {
    return false
  }

  if (hasParent !== hasIndex) {
    throw new Error('Expected both parent and index')
  }

  return Boolean(check.call(context, node, index, parent))
}
761504
function (node) {
        var parent = node.parentNode;
        while (parent) {
            if (parent === this) {
                return true;
            }
            parent = parent.parentNode;
        }
        return false;
    }
581914
static boolean isClassExpression(Node n) {
    return n.isClass() && (!isNamedClass(n) || !isDeclarationParent(n.getParent()));
  }
660242
public boolean isEnclosing(Scope scope) {
        for (; scope != null; scope = scope.getParent()) {
            if (this == scope) {
                return true;
            }
        }
        return false;
    }
745422
public static boolean isFallbackOf(Locale parent, Locale child) {
        return isFallbackOf(parent.toString(), child.toString());
    }
409837
public boolean isChildOf(NameSpace parent) {
        return null != this.getParent() && (
                this.getParent().equals(parent)
             || this.getParent().isChildOf(parent));
    }
1152024
public static boolean isSubclassOf(ClassNode classNode, String parentClassName) {
        ClassNode currentSuper = classNode.getSuperClass();
        while (currentSuper != null && !currentSuper.getName().equals(OBJECT_CLASS)) {
            if (currentSuper.getName().equals(parentClassName)) return true;
            currentSuper = currentSuper.getSuperClass();
        }
        return false;
    }
552440
public boolean wrapInAnchor() {
        if (ext(ANCHORLINKS | EXTANCHORLINKS)) {
            SuperNode node = (SuperNode) peek();
            List<Node> children = node.getChildren();
            if (ext(EXTANCHORLINKS)) {
                if (children.size() > 0) {
                    AnchorNodeInfo nodeInfo = new AnchorNodeInfo();
                    collectChildrensText(node, nodeInfo);
                    String text = nodeInfo.text.toString().trim();
                    if (text.length() > 0) {
                        AnchorLinkNode anchor = new AnchorLinkNode(text, "");
                        anchor.setStartIndex(nodeInfo.startIndex);
                        anchor.setEndIndex(nodeInfo.endIndex);
                        children.add(0, anchor);
                    }
                }
            } else {
                if (children.size() == 1) {
                    Node child = children.get(0);
                    if (child instanceof TextNode) {
                        AnchorLinkNode anchor = new AnchorLinkNode(((TextNode) child).getText());
                        anchor.setStartIndex(child.getStartIndex());
                        anchor.setEndIndex(child.getEndIndex());
                        children.set(0, anchor);
                    }
                }
            }
        }

        return true;
    }
599441
function() {
			var i,
				l,
				parents = this.getParentList(false, false);

			for (i = 0, l = parents.length; i < l; i++) {
				if (!parents[i].expanded) {
					return false;
				}
			}
			return true;
		}
1114185
public boolean hasNext() {

        if (items != null) {
            if (items.hasNext()) {
                return (true);
            } else {
                items = null;
            }
        }
        Object next = findNextValidChild();
        while (next != null) {
            initializeItems(next);
            if (items != null) {
                return true;
            } else {
                next = findNextValidChild();
            }
        }
        return false;

    }
543826
public boolean isParent(RegistryEntry registryEntry) {
		RegistryEntry parentRegistryEntry = getParentRegistryEntry();
		while (parentRegistryEntry != null) {
			if (parentRegistryEntry.equals(registryEntry)) {
				return true;
			}
			parentRegistryEntry = parentRegistryEntry.getParentRegistryEntry();
		}
		return false;
	}
643063
public static <T> boolean isDescendantOfOrEqualTo(TreeDef.Parented<T> treeDef, T child, T parent) {
		if (child.equals(parent)) {
			return true;
		} else {
			return isDescendantOf(treeDef, child, parent);
		}
	}
1111272
public boolean parent() {
        if (mNode == null) {
            return false;
        }
        AccessibilityNodeInfoCompat parentNode = mNode.getParent();
        while (parentNode != null) {
            if (AccessibilityNodeInfoUtils.isVisibleOrLegacy(parentNode)) {
                reset(parentNode);
                return true;
            }
            AccessibilityNodeInfoCompat tmp = parentNode.getParent();
            parentNode.recycle();
            parentNode = tmp;
        }
        return false;
    }