共通パス名:os.path.commonprefix(パスのリスト) は,パスのシーケンスの先頭の共通部分(文字比較)を返します.
import os.path
bin = '/usr/local/abc/bin'
lib = '/usr/local/abab/lib'
help = '/usr/local/ab/help'
paths = [bin, lib, help]
common = os.path.commonprefix(paths)
print(common)
/usr/local/ab