private static boolean isSynchronizedOnThis(@NotNull PsiElement element) {
      final PsiElement context = PsiTreeUtil.getParentOfType(element, PsiMethod.class, PsiSynchronizedStatement.class);
      if (context instanceof PsiSynchronizedStatement synchronizedStatement) {
        final PsiExpression lockExpression = PsiUtil.skipParenthesizedExprDown(synchronizedStatement.getLockExpression());
        return lockExpression instanceof PsiThisExpression || isSynchronizedOnThis(synchronizedStatement);
      }
      else if (context instanceof PsiMethod method) {
        if (method.hasModifierProperty(PsiModifier.SYNCHRONIZED)) {
          return true;
        }
      }
      return false;
    }
private static boolean isSynchronizedOnThis(@NotNull PsiElement element)