YAMLValue (@Nullable YAMLPsiElement element) { if (element == null) { return null; } Ref<YAMLValue> result = Ref.create(); element.accept(new YamlPsiElementVisitor() { @Override public void visitKeyValue(@NotNull YAMLKeyValue keyValue) { result.set(keyValue.getValue()); } @Override public void visitSequenceItem(@NotNull YAMLSequenceItem sequenceItem) { result.set(sequenceItem.getValue()); } }); return result.get(); }