Code Duplication    Length = 3-7 lines in 2 locations

code/Model/SiteTree.php 2 locations

@@ 390-396 (lines=7) @@
387
        if (!$sitetree) {
388
            $parentID = self::config()->nested_urls ? 0 : null;
389
390
            if ($alternatives = static::singleton()->extend('alternateGetByLink', $URLSegment, $parentID)) {
391
                foreach ($alternatives as $alternative) {
392
                    if ($alternative) {
393
                        $sitetree = $alternative;
394
                    }
395
                }
396
            }
397
398
            if (!$sitetree) {
399
                return null;
@@ 422-424 (lines=3) @@
419
            if (!$next) {
420
                $parentID = (int) $sitetree->ID;
421
422
                if ($alternatives = static::singleton()->extend('alternateGetByLink', $segment, $parentID)) {
423
                    foreach ($alternatives as $alternative) {
424
                        if ($alternative) {
425
                            $next = $alternative;
426
                        }
427
                    }