private static function countCommonDepth($from, $to) { $depth = 0; while (isset($from[$depth], $to[$depth]) && $from[$depth] === $to[$depth]) { $depth += 1; } return $depth; }