Code Duplication    Length = 3-7 lines in 2 locations

code/Model/SiteTree.php 2 locations

@@ 384-390 (lines=7) @@
381
        if (!$sitetree) {
382
            $parentID = self::config()->nested_urls ? 0 : null;
383
384
            if ($alternatives = static::singleton()->extend('alternateGetByLink', $URLSegment, $parentID)) {
385
                foreach ($alternatives as $alternative) {
386
                    if ($alternative) {
387
                        $sitetree = $alternative;
388
                    }
389
                }
390
            }
391
392
            if (!$sitetree) {
393
                return null;
@@ 416-418 (lines=3) @@
413
            if (!$next) {
414
                $parentID = (int) $sitetree->ID;
415
416
                if ($alternatives = static::singleton()->extend('alternateGetByLink', $segment, $parentID)) {
417
                    foreach ($alternatives as $alternative) {
418
                        if ($alternative) {
419
                            $next = $alternative;
420
                        }
421
                    }