diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/client/api/gui/DataSetPickerDialog.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/client/api/gui/DataSetPickerDialog.java
index 4d9d59b61b3d51f352573e0bc9a0fb866af46163..29cad1f2250084fdd538ea4fc4a0464df7a630f8 100644
--- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/client/api/gui/DataSetPickerDialog.java
+++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/client/api/gui/DataSetPickerDialog.java
@@ -203,13 +203,27 @@ public class DataSetPickerDialog extends AbstractEntityPickerDialogWithServerCon
 
         Object value = optionPane.getValue();
         optionPane.setValue(optionPane.getInitialValue());
-        if (value == null || ((Integer) value).intValue() == JOptionPane.CANCEL_OPTION)
+        if (isDataSetPicked(value))
         {
-            return null;
+            return tree.getSelectionPath().getLastPathComponent().toString();
         } else
         {
-            return tree.getSelectionPath().getLastPathComponent().toString();
+            return null;
+        }
+    }
+
+    private boolean isDataSetPicked(Object optionPaneValue)
+    {
+        if (optionPaneValue == null
+                || ((Integer) optionPaneValue).intValue() == JOptionPane.CANCEL_OPTION)
+        {
+            return false;
+        }
+        if (tree.getSelectionPath() == null)
+        {
+            return false;
         }
+        return true;
     }
 
     public void treeWillExpand(TreeExpansionEvent event) throws ExpandVetoException