def METHOD_NAME(self, filename):
    # We only take the dirname if we have a path to a non-dir,
    # because taking the dirname of a symlink to a directory does not
    # give the actual directory parent.
    if os.path.isdir(filename):
        return filename
    else:
        return os.path.dirname(filename)