code: public static AbstractFile getFirstRootFileByName(final SecurityContext securityContext, final String name) {
  
  		logger.debug("Search for file with name: {}", name);
  
  		try {
  			final List<AbstractFile> files = StructrApp.getInstance(securityContext).nodeQuery(AbstractFile.class).andName(name).getAsList();
  
  			for (final AbstractFile file : files) {
  
  				if (file.getParent() == null) {
  					return file;
  				}
  
  			}
  
  		} catch (FrameworkException fex) {
  
  			logger.warn("Unable to find a file for name {}: {}", name, fex.getMessage());
  		}
  
  		return null;
  	}
docs: Find the first file with given name on root level (without parent folder).
  
  @param securityContext
  @param name
  @return file