This function has the same signature as the pre-v3 filter() returning a
    compatibility CompatNodeIterator.
503071
def filter(n: Node, query: str) -> CompatNodeIterator:
    
    ctx = uast()
    return CompatNodeIterator(NodeIterator(ctx.filter(query, n.internal_node), ctx))
350077
function signatureRelatedTo(source, target, reportErrors) {
                return compareSignaturesRelated(source, target, /*ignoreReturnTypes*/ false, reportErrors, reportError, isRelatedTo);
            }
663199
public static <T, U> SameType<T> of(TreeNode<T> expected, TreeDef<U> treeDef, U actual, Function<? super U, ? extends T> mapper) {
		return of(TreeNode.treeDef(), expected, treeDef, actual).mapToSame(TreeNode::getContent, mapper);
	}
1280863
function recursivelyMatch(className, where) {
  debugPrint('MATCH', { className, where });
  const collection = getCollection(className);
  // eslint-disable-next-line no-use-before-define
  const matches = _.filter(_.values(collection), queryFilter(where));
  debugPrint('MATCHES', { matches });
  return _.cloneDeep(matches); // return copies instead of originals
}
233875
function compatibleTypes(x,y) {
	if (x === y)
		return true;
	if (x instanceof TQualifiedReference && y instanceof TQualifiedReference)
		return x.qname === y.qname;
	return false;
}
134757
static ModelNode filterSpecToFilter(final String value) {
        final ModelNode filter = new ModelNode(CommonAttributes.FILTER.getName()).setEmptyObject();
        final Iterator<String> iterator = tokens(value).iterator();
        parseFilterExpression(iterator, filter, true);
        return filter;
    }
1222432
function compareAst(actualSrc, expectedSrc, options) {
	var actualAst, expectedAst;
	options = options || {};

	if (!options.comparators) {
		options.comparators = [];
	}

	/*
	 * A collection of comparator functions that recognize equivalent nodes
	 * that would otherwise be reported as unequal by simple object comparison.
	 * These may:
	 *
	 * - return `true` if the given nodes can be verified as equivalent with no
	 *   further processing
	 * - return an instance of MatchError if the nodes are verified as
	 *   uniquivalent
	 * - return any other value if equivalency cannot be determined
	 */
	Array.prototype.push.apply(options.comparators, [
		require('./comparators/fuzzy-identifiers')(options),
		require('./comparators/fuzzy-strings')(options)
	]);

	try {
		actualAst = parse(actualSrc).body;
	} catch(err) {
		throw new Errors.ParseError();
	}

	try {
		expectedAst = parse(expectedSrc).body;
	} catch (err) {
		throw new Errors.ParseError();
	}

	function _bind(actual, expected) {
		var attr;

		// Literal values
		if (Object(actual) !== actual) {
			if (actual !== expected) {
				throw new Errors.MatchError(actualAst, expectedAst);
			}
			return;
		}

		// Arrays
		if (Array.isArray(actual)) {
			if (actual.length !== expected.length) {
				throw new Errors.MatchError(actualAst, expectedAst);
			}
			actual.forEach(function(_, i) {
				_bind(actual[i], expected[i]);
			});
			return;
		}

		// Nodes

		normalizeMemberExpr(actual);
		normalizeMemberExpr(expected);

		if (checkEquivalency(options.comparators, actual, expected)) {
			return;
		}

		// Either remove attributes or recurse on their values
		for (attr in actual) {
			if (expected && attr in expected) {
				_bind(actual[attr], expected[attr]);
			} else {
				throw new Errors.MatchError(actualAst, expectedAst);
			}
		}
	}

	// Start recursing on the ASTs from the top level.
	_bind(actualAst, expectedAst);

	return null;
}
611306
public static FilterBuilder any(final Predicate... alternatives) {
		return new CommonFilterBuilder() {
			@Override
			public boolean matches(Class<?> klass) {
				for (Predicate alternative : alternatives) {
					if (alternative.matches(klass)) {
						return true;
					}
				}
				return false;
			}
		};
	}
510219
function compareSignaturesIdentical(source, target, partialMatch, ignoreThisTypes, ignoreReturnTypes, compareTypes) {
            // TODO (drosen): De-duplicate code between related functions.
            if (source === target) {
                return -1 /* True */;
            }
            if (!(isMatchingSignature(source, target, partialMatch))) {
                return 0 /* False */;
            }
            // Check that the two signatures have the same number of type parameters. We might consider
            // also checking that any type parameter constraints match, but that would require instantiating
            // the constraints with a common set of type arguments to get relatable entities in places where
            // type parameters occur in the constraints. The complexity of doing that doesn't seem worthwhile,
            // particularly as we're comparing erased versions of the signatures below.
            if ((source.typeParameters ? source.typeParameters.length : 0) !== (target.typeParameters ? target.typeParameters.length : 0)) {
                return 0 /* False */;
            }
            // Spec 1.0 Section 3.8.3 & 3.8.4:
            // M and N (the signatures) are instantiated using type Any as the type argument for all type parameters declared by M and N
            source = getErasedSignature(source);
            target = getErasedSignature(target);
            var result = -1 /* True */;
            if (!ignoreThisTypes) {
                var sourceThisType = getThisTypeOfSignature(source);
                if (sourceThisType) {
                    var targetThisType = getThisTypeOfSignature(target);
                    if (targetThisType) {
                        var related = compareTypes(sourceThisType, targetThisType);
                        if (!related) {
                            return 0 /* False */;
                        }
                        result &= related;
                    }
                }
            }
            var targetLen = target.parameters.length;
            for (var i = 0; i < targetLen; i++) {
                var s = isRestParameterIndex(source, i) ? getRestTypeOfSignature(source) : getTypeOfParameter(source.parameters[i]);
                var t = isRestParameterIndex(target, i) ? getRestTypeOfSignature(target) : getTypeOfParameter(target.parameters[i]);
                var related = compareTypes(s, t);
                if (!related) {
                    return 0 /* False */;
                }
                result &= related;
            }
            if (!ignoreReturnTypes) {
                result &= compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target));
            }
            return result;
        }
239800
public static <T> Iterator<T> filteringIterator(
        Iterator<? extends T> iterator, 
        Predicate<? super T> predicate)
    {
        Objects.requireNonNull(iterator, "The iterator is null");
        Objects.requireNonNull(predicate, "The predicate is null");
        return new FilteringIterator<T>(iterator, predicate);
    }
533390
protected int compatibilityGraphNodes() throws IOException {

        compGraphNodes.clear();
        List<IAtom> basicAtomVecA = null;
        List<IAtom> basicAtomVecB = null;
        IAtomContainer reactant = source;
        IAtomContainer product = target;

        basicAtomVecA = reduceAtomSet(reactant);
        basicAtomVecB = reduceAtomSet(product);

        List<List<Integer>> labelListMolA = labelAtoms(reactant);
        List<List<Integer>> labelListMolB = labelAtoms(product);

        int molANodes = 0;
        int countNodes = 1;

        for (List<Integer> labelA : labelListMolA) {
            int molBNodes = 0;
            for (List<Integer> labelB : labelListMolB) {
                if (labelA.equals(labelB)) {
                    compGraphNodes.add(reactant.indexOf(basicAtomVecA.get(molANodes)));
                    compGraphNodes.add(product.indexOf(basicAtomVecB.get(molBNodes)));
                    compGraphNodes.add(countNodes++);
                }
                molBNodes++;
            }
            molANodes++;
        }
        return 0;
    }
75272
def function_inclusion_filter_builder(func: Strings) -> NodePredicate:
    
    if isinstance(func, str):
        return _single_function_inclusion_filter_builder(func)

    elif isinstance(func, Iterable):
        return _collection_function_inclusion_builder(func)

    raise TypeError('Invalid type for argument: {}'.format(func))
523272
function processOtherSpecifier() {
                    const leftBrace = sourceCode.getFirstToken(node, 1)
                    const rightBrace = sourceCode.getLastToken(
                        node,
                        hasSemi ? 3 : 2
                    )
                    setOffsetToToken(leftBrace, 0, importToken)
                    processNodeList(node.specifiers, leftBrace, rightBrace, 1)
                    tokens.push(
                        sourceCode.getLastToken(node, hasSemi ? 2 : 1), // from
                        sourceCode.getLastToken(node, hasSemi ? 1 : 0) // "foo"
                    )
                }
853546
public static <T, ET extends T, B1> DecomposableMatchBuilder1<List<T>, B1> headTail(
      DecomposableMatchBuilder0<ET> head, DecomposableMatchBuilder1<List<T>, B1> tail) {
    List<Matcher<Object>> matchers = Lists.of(ArgumentMatchers.any(), ArgumentMatchers.any());
    return new DecomposableMatchBuilder2<List<T>, ET, List<T>>(
        matchers, Tuple2.of(0, 1), new ListConsHeadTailFieldExtractor<>())
        .decomposeFirstAndSecond(head, tail);
  }
1313282
private boolean isSimilarSignature(Method possiblyMatchingMethod, String desiredMethodName, Class<?>[] desiredParamTypes) {
        return possiblyMatchingMethod.getName().equals(desiredMethodName) && match(possiblyMatchingMethod.getParameterTypes(), desiredParamTypes);
    }
375518
def _anonymous_match(self, struct1, struct2, fu, s1_supercell=True,
                         use_rms=False, break_on_match=False, single_match=False):
        
        if not isinstance(self._comparator, SpeciesComparator):
            raise ValueError('Anonymous fitting currently requires SpeciesComparator')

        # check that species lists are comparable
        sp1 = struct1.composition.elements
        sp2 = struct2.composition.elements
        if len(sp1) != len(sp2):
            return None

        ratio = fu if s1_supercell else 1/fu
        swapped = len(struct1) * ratio < len(struct2)

        s1_comp = struct1.composition
        s2_comp = struct2.composition
        matches = []
        for perm in itertools.permutations(sp2):
            sp_mapping = dict(zip(sp1, perm))

            # do quick check that compositions are compatible
            mapped_comp = Composition({sp_mapping[k]: v
                                       for k, v in s1_comp.items()})
            if (not self._subset) and (
                    self._comparator.get_hash(mapped_comp) !=
                    self._comparator.get_hash(s2_comp)):
                continue

            mapped_struct = struct1.copy()
            mapped_struct.replace_species(sp_mapping)
            if swapped:
                m = self._strict_match(struct2, mapped_struct, fu,
                                       (not s1_supercell), use_rms,
                                       break_on_match)
            else:
                m = self._strict_match(mapped_struct, struct2, fu, s1_supercell,
                                       use_rms, break_on_match)
            if m:
                matches.append((sp_mapping, m))
                if single_match:
                    break
        return matches
506444
private static <T> T filterBySupportedProperties(
		Class<T> factoryClass,
		Map<String, String> properties,
		List<TableFactory> foundFactories,
		List<TableFactory> classFactories) {

		final List<String> plainGivenKeys = new LinkedList<>();
		properties.keySet().forEach(k -> {
			// replace arrays with wildcard
			String key = k.replaceAll(".\\d+", ".#");
			// ignore duplicates
			if (!plainGivenKeys.contains(key)) {
				plainGivenKeys.add(key);
			}
		});

		Optional<String> lastKey = Optional.empty();
		List<TableFactory> supportedFactories = new LinkedList<>();
		for (TableFactory factory: classFactories) {
			Set<String> requiredContextKeys = normalizeContext(factory).keySet();
			Tuple2<List<String>, List<String>> tuple2 = normalizeSupportedProperties(factory);
			// ignore context keys
			List<String> givenContextFreeKeys = plainGivenKeys.stream()
				.filter(p -> !requiredContextKeys.contains(p))
				.collect(Collectors.toList());
			List<String> givenFilteredKeys = filterSupportedPropertiesFactorySpecific(
				factory,
				givenContextFreeKeys);

			Boolean allTrue = true;
			for (String k: givenFilteredKeys) {
				lastKey = Optional.of(k);
				if (!(tuple2.f0.contains(k) || tuple2.f1.stream().anyMatch(p -> k.startsWith(p)))) {
					allTrue = false;
					break;
				}
			}
			if (allTrue) {
				supportedFactories.add(factory);
			}
		}

		if (supportedFactories.isEmpty() && classFactories.size() == 1 && lastKey.isPresent()) {
			// special case: when there is only one matching factory but the last property key
			// was incorrect
			TableFactory factory = classFactories.get(0);
			Tuple2<List<String>, List<String>> tuple2 = normalizeSupportedProperties(factory);

			String errorMessage = String.format(
				"The matching factory '%s' doesn't support '%s'.\n\nSupported properties of " +
					"this factory are:\n%s",
				factory.getClass().getName(),
				lastKey.get(),
				String.join("\n", tuple2.f0));

			throw new NoMatchingTableFactoryException(
				errorMessage,
				factoryClass,
				foundFactories,
				properties);
		} else if (supportedFactories.isEmpty()) {
			throw new NoMatchingTableFactoryException(
				"No factory supports all properties.",
				factoryClass,
				foundFactories,
				properties);
		} else if (supportedFactories.size() > 1) {
			throw new AmbiguousTableFactoryException(
				supportedFactories,
				factoryClass,
				foundFactories,
				properties);
		}

		return (T) supportedFactories.get(0);
	}