Code Duplication    Length = 3-7 lines in 2 locations

code/Model/SiteTree.php 2 locations

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