Couple<Integer> (SingleChildDescriptor childDescriptor, PsiFragment parentFragment, NodeSpecificHasher nodeSpecificHasher) { final PsiElement element = childDescriptor.getElement(); if (element == null) { return Couple.of(0, 0); } return switch (childDescriptor.getType()) { case OPTIONALLY_IN_PATTERN, DEFAULT -> { final TreeHashResult result = hash(element, parentFragment, nodeSpecificHasher); yield Couple.of(result.getHash(), result.getCost()); } case CHILDREN_OPTIONALLY_IN_PATTERN, CHILDREN -> hashChildResults(computeHashesForChildren(element, parentFragment, nodeSpecificHasher), 31); case CHILDREN_IN_ANY_ORDER -> hashChildResults(computeHashesForChildren(element, parentFragment, nodeSpecificHasher), 1); default -> Couple.of(0, 0); }; }