private static CompareInfo fromMap(@Nullable Map<Integer, PsiExpression> map,
                                     @NotNull PsiExpression expression,
                                     @NotNull PsiElement template) {
    if (map == null || map.size() != 3) {
      return null;
    }
    PsiExpression lt = map.get(-1);
    Pair<PsiExpression, PsiExpression> ltPair = getOperands(lt, JavaTokenType.LT);
    if (lt != null && ltPair == null) return null;

    PsiExpression gt = map.get(1);
    Pair<PsiExpression, PsiExpression> gtPair = getOperands(gt, JavaTokenType.GT);
    if ((gt != null || ltPair == null) && gtPair == null) return null;

    if (ltPair != null && gtPair != null) {
      if (!PsiEquivalenceUtil.areElementsEquivalent(ltPair.getFirst(), gtPair.getFirst())) return null;
      if (!PsiEquivalenceUtil.areElementsEquivalent(ltPair.getSecond(), gtPair.getSecond())) return null;
    }
    Pair<PsiExpression, PsiExpression> canonicalPair = ltPair == null ? gtPair : ltPair;
    PsiType leftType = canonicalPair.getFirst().getType();
    PsiType rightType = canonicalPair.getSecond().getType();
    if (!isTypeConvertible(leftType, expression) || !leftType.equals(rightType)) return null;

    PsiExpression eq = map.get(0);
    Pair<PsiExpression, PsiExpression> eqPair = getOperands(eq, JavaTokenType.EQEQ);
    if (eq != null && eqPair == null) return null;
    if (eqPair != null) {
      if ((!PsiEquivalenceUtil.areElementsEquivalent(canonicalPair.getFirst(), eqPair.getFirst()) ||
           !PsiEquivalenceUtil.areElementsEquivalent(canonicalPair.getSecond(), eqPair.getSecond())) &&
          (!PsiEquivalenceUtil.areElementsEquivalent(canonicalPair.getFirst(), eqPair.getSecond()) ||
           !PsiEquivalenceUtil.areElementsEquivalent(canonicalPair.getSecond(), eqPair.getFirst()))) {
        return null;
      }
    }
    PsiClassType boxedType = leftType instanceof PsiPrimitiveType ? ((PsiPrimitiveType)leftType).getBoxedType(expression) :
                             tryCast(leftType, PsiClassType.class);
    if (boxedType == null) return null;
    return new CompareInfo(template, expression, canonicalPair.getFirst(), canonicalPair.getSecond(), boxedType,
                           TypeConversionUtil.isFloatOrDoubleType(boxedType));
  }
private static CompareInfo fromMap(@Nullable Map<Integer, PsiExpression> map,
                                     @NotNull PsiExpression expression,
                                     @NotNull PsiElement template)