Code Duplication    Length = 3-7 lines in 2 locations

code/Model/SiteTree.php 2 locations

@@ 351-357 (lines=7) @@
348
        if (!$sitetree) {
349
            $parentID = self::config()->nested_urls ? 0 : null;
350
351
            if ($alternatives = static::singleton()->extend('alternateGetByLink', $URLSegment, $parentID)) {
352
                foreach ($alternatives as $alternative) {
353
                    if ($alternative) {
354
                        $sitetree = $alternative;
355
                    }
356
                }
357
            }
358
359
            if (!$sitetree) {
360
                return null;
@@ 383-385 (lines=3) @@
380
            if (!$next) {
381
                $parentID = (int) $sitetree->ID;
382
383
                if ($alternatives = static::singleton()->extend('alternateGetByLink', $segment, $parentID)) {
384
                    foreach ($alternatives as $alternative) {
385
                        if ($alternative) {
386
                            $next = $alternative;
387
                        }
388
                    }