@Override
  public @NotNull PsiElementVisitor buildVisitor(final @NotNull ProblemsHolder holder, boolean isOnTheFly) {
    return new YamlPsiElementVisitor() {
      @Override
      public void visitAlias(@NotNull YAMLAlias alias) {
        YAMLAliasReference reference = alias.getReference();
        YAMLAnchor anchor = reference == null ? null: reference.resolve();
        YAMLValue value = anchor == null ? null : anchor.getMarkedValue();
        if (value == null) {
          return;
        }

        if (PsiTreeUtil.isAncestor(value, alias.getParent(), false)) {
          holder.registerProblem(
            reference,
            YAMLBundle.message("inspections.recursive.alias.message"),
            ProblemHighlightType.GENERIC_ERROR_OR_WARNING
          );
        }
      }
    };
  }
@Override
  public @NotNull PsiElementVisitor buildVisitor(final @NotNull ProblemsHolder holder, boolean isOnTheFly)