code: public static File getExistingFile(final String path, final File baseDir) {
  
          // Check sanity
          Validate.notEmpty(path, "path");
          final File theFile = new File(path);
          File toReturn = null;
  
          // Is 'path' absolute?
          if (theFile.isAbsolute() && (EXISTING_FILE.accept(theFile) || EXISTING_DIRECTORY.accept(theFile))) {
              toReturn = getCanonicalFile(theFile);
          }
  
          // Is 'path' relative?
          if (!theFile.isAbsolute()) {
  
              // In this case, baseDir cannot be null.
              Validate.notNull(baseDir, "baseDir");
              final File relativeFile = new File(baseDir, path);
  
              if (EXISTING_FILE.accept(relativeFile) || EXISTING_DIRECTORY.accept(relativeFile)) {
                  toReturn = getCanonicalFile(relativeFile);
              }
          }
  
          // The path provided did not point to an existing File or Directory.
          return toReturn;
      }
docs: <p>Retrieves the canonical File matching the supplied path in the following order or priority:</p>
  <ol>
  <li><strong>Absolute path:</strong> The path is used by itself (i.e. {@code new File(path);}). If an
  existing file or directory matches the provided path argument, its canonical path will be returned.</li>
  <li><strong>Relative path:</strong> The path is appended to the baseDir (i.e.
  {@code new File(baseDir, path);}). If an existing file or directory matches the provided path argument,
  its canonical path will be returned. Only in this case will be baseDir argument be considered.</li>
  </ol>
  <p>If no file or directory could be derived from the supplied path and baseDir, {@code null} is returned.</p>
  
  @param path    A non-null path which will be used to find an existing file or directory.
  @param baseDir A directory to which the path will be appended to search for the existing file or directory in
  case the file was nonexistent when interpreted as an absolute path.
  @return either a canonical File for the path, or {@code null} if no file or directory matched
  the supplied path and baseDir.