tools/pkgutils.py: recursively searching up for .git directory

in tools/pkgutils.py: recursively searching up for .git directory until reaching / on Unix or drive root on Windows