@Nullable
  private static ObjectReference getSelectedReference(InstancesTree tree) {
    TreePath selectionPath = tree.getSelectionPath();
    Object selectedItem = selectionPath != null ? selectionPath.getLastPathComponent() : null;
    if (selectedItem instanceof XValueNodeImpl xValueNode &&
        xValueNode.getValueContainer() instanceof NodeDescriptorProvider descriptorProvider &&
        descriptorProvider.getDescriptor() instanceof ValueDescriptor valueDescriptor) {
      return ObjectUtils.tryCast(valueDescriptor.getValue(), ObjectReference.class);
    }

    return null;
  }
@Nullable
  private static ObjectReference getSelectedReference(InstancesTree tree)