You could use Content Services's searchService to ascertain whether the node(document or space) exists in the repository or not.The only issue with this is that searchService is not orchestrable.So, call can be by using DocumentManagementServiceClient in an executeScript operation.
Here is a sample code used to search for "Company Home->def->def.properties".
import com.adobe.idp.dsc.clientsdk.ServiceClientFactory;
import com.adobe.livecycle.contentservices.client.Query;
import com.adobe.livecycle.contentservices.client.ResultSet ;
import com.adobe.livecycle.contentservices.client.impl.QueryImpl;
import com.adobe.livecycle.contentservices.client.DocumentManagementServiceClient;
import com.adobe.livecycle.contentservices.client.impl.DocumentManagementServiceClientImpl;
DocumentManagementServiceClient docManagementServiceClient =
new DocumentManagementServiceClientImpl(ServiceClientFactory.createInstance());
String storeName ="SpacesStore";
String queryString = "PATH:\"/app:company_home/cm:def/cm:def.pdf\"";// a properly escaped lucene query.
//the default nodes are preceeded by app prefix where as new user created nodes are prefixed by "cm" prefix
Query query = new QueryImpl();
query.setQueryString(queryString);
ResultSet rs = docManagementServiceClient.searchRepository(storeName, "nebulous", true, query, Integer.MAX_VALUE);
String nodeId= rs.getMatchingIDs().get(0);// You could use rs.getMatchingIDs().size(). If it is 0, node does not exist.
patExecContext.setProcessDataValue("/process_data/outputParam", nodeId);
For userhomes, the query used is this :- PATH:"/app:company_home/app:user_homes" (Need to be escaped when used in code)
Verifying queries :You could go to company home->Administrative Console-> node browser.From there select spacesStore and in the search option drop down, select "lucene". In the text field, type the lucene query and click "search" to verify.
Hope this helps,
Sourabh