Ensure path is a directory, use parent directory if it is a file