private boolean canBeJoinedWith(@NotNull BranchBase<?> other) {
      //for default branch, it is always possible to delete another branch.
      //see also BranchBase.mergeWithDefaultFix
      if (isDefault() || other.isDefault()) return true;

      //fast exist
      if (!this.canMergeBranch()) return false;
      if (!other.canMergeBranch()) return false;
      boolean thisPattern = hasPattern(getLabels());
      boolean otherPattern = hasPattern(other.getLabels());
      if (otherPattern != thisPattern) return false;
      //usual switch, it doesn't have guards and dominance
      if (!thisPattern) return true;


      if (this instanceof Rule) {
        PsiExpression thisGuard = myFirstLabel.getGuardExpression();
        PsiExpression otherGuard = other.myFirstLabel.getGuardExpression();
        //it's impossible to merge if one case has guard, but another doesn't
        if ((thisGuard == null && otherGuard != null) ||
            (thisGuard != null && otherGuard == null)) {
          return false;
        }

        if (thisGuard != null) {
          //IDEA always moves to upper position, so it cannot be dominated
          return createFinder(new PsiElement[]{thisGuard}).isDuplicate(otherGuard, true) != null;
        }
      }

      if (this instanceof Branch) {
        PsiExpression thisGuard = myFirstLabel.getGuardExpression();
        PsiExpression otherGuard = other.myFirstLabel.getGuardExpression();
        if (thisGuard != null && otherGuard != null) {
          //IDEA always moves to upper position, so it cannot be dominated
          return true;
        }
      }

      return isNearby(other);
    }
private boolean canBeJoinedWith(@NotNull BranchBase<?> other)