String customWorkspace = getParent().getParent().getCustomWorkspace();
if (customWorkspace != null) {
// Use custom workspace as defined in the matrix project settings.
FilePath ws = n.getRootPath().child(getEnvironment(listener).expand(customWorkspace));
// We allow custom workspaces to be used concurrently between jobs.
return Lease.createDummyLease(ws.child(subtree));
} else {
// Use default workspace as assigned by Hudson.
Node node = getBuiltOn();
FilePath ws = node.getWorkspaceFor(getParent().getParent());
// Allocate unique workspace (not to be shared between jobs and runs).