def _search_chimera(binary, directories, prefix, search_all=False):
    """
    Try running ``chimera --root`` if Chimera happens to be in PATH, otherwise
    traverse usual installation locations to find the Chimera root path.

    Parameters
    ----------
    binary : str
        Name of the chimera executable in this platform
    directories: list of str
        Usual installation locations in this platform
    prefix : str
        Root directory prefix name in this platform
    search_all : bool, optional, default=False
        Collect all posible locations of Chimera installations, even if a
        binary has been found.

    Returns
    -------
    paths : list of str
        Sorted list of Chimera paths. If found, the first one is the one returned
        by the binary call. Next items are the ones found in `directories`, sorted
        by descendent order.
    """
    # First, check if environment variable is already present
    try:
        return os.path.expanduser(os.environ['CHIMERADIR']),
    except KeyError:
        pass

    paths = []
    binary_path = find_executable(binary)
    if binary_path is not None:
        real_path = os.path.realpath(binary_path)  # follow symlinks
        chimera_dir = os.path.sep + os.path.join(*real_path.split(os.path.sep)[1:-2])
        paths.append(chimera_dir)
    else:
        search_all = True

    if search_all:
        for basedir in directories:
            found_paths = filter(os.path.isdir, glob(os.path.join(basedir, prefix)))
            if found_paths:
                found_paths.sort()
                found_paths.reverse()
                paths.extend(found_paths)
    seen = set()
    paths = [p for p in paths if p not in seen and not seen.add(p)]
    return paths
Try running ``chimera --root`` if Chimera happens to be in PATH, otherwise
    traverse usual installation locations to find the Chimera root path.

    Parameters
    ----------
    binary : str
        Name of the chimera executable in this platform
    directories: list of str
        Usual installation locations in this platform
    prefix : str
        Root directory prefix name in this platform
    search_all : bool, optional, default=False
        Collect all posible locations of Chimera installations, even if a
        binary has been found.

    Returns
    -------
    paths : list of str
        Sorted list of Chimera paths. If found, the first one is the one returned
        by the binary call. Next items are the ones found in `directories`, sorted
        by descendent order.