CommonFile: refactored 'findMaximalPrefix'