protected function whichFrom($binary, array $locations)
    {
        $location = false;

        // Look in all the locations
        $tryout = 0;
        while (!$location && array_key_exists($tryout, $locations)) {
            // Execute method if required
            $location = $locations[$tryout];
            if (is_array($location)) {
                list($object, $method, $argument) = $location;
                $location = $object->$method($argument);
            }

            // Verify existence of returned path
            if ($location && $location !== $this->paths->getPath($binary)) {
                $location = $this->rawWhich($location);
            }

            ++$tryout;
        }

        // Store found location or remove it if invalid
        if (!$this->modulable->connections->is('local')) {
            if ($location) {
                $this->localStorage->set($this->getBinaryStoragePath($binary), $location);
            } else {
                $this->localStorage->forget($this->getBinaryStoragePath($binary));
            }
        }

        return $location ?: $binary;
    }