public function resolvePath($path, $extensions = null)
    {

        $paths = $this->options['paths'];
        $exts = $extensions ? $extensions : $this->options['extensions'];

        if (is_array($exts)) {

            foreach ($exts as $ext)
                if ($resolved = $this->resolvePath($path, $ext))
                    return $resolved;

            return false;
        }

        $ext = $exts;

        if (substr($path, -strlen($ext)) !== $ext)
            $path .= $ext;

        //Check static path
        if (file_exists($path))
            return $path;

        if (count($paths) < 1) {

            //We got no paths to search in. We use the include-path in that case
            $paths = explode(\PATH_SEPARATOR, get_include_path());
        }

        //Add the path were currently compiling in (e.g. include, extends)
        if (count($this->files) > 0)
            $paths[] = dirname(end($this->files));

        //Iterate paths and check file existence via realpath
        foreach ($paths as $directory) {

            $fullPath = realpath(rtrim($directory, '/\\').'/'.ltrim($path, '/\\'));

            if ($fullPath)
                return $fullPath;
        }

        return false;
    }