Code Duplication    Length = 3-7 lines in 2 locations

code/Model/SiteTree.php 2 locations

@@ 377-383 (lines=7) @@
374
        if (!$sitetree) {
375
            $parentID = self::config()->nested_urls ? 0 : null;
376
377
            if ($alternatives = static::singleton()->extend('alternateGetByLink', $URLSegment, $parentID)) {
378
                foreach ($alternatives as $alternative) {
379
                    if ($alternative) {
380
                        $sitetree = $alternative;
381
                    }
382
                }
383
            }
384
385
            if (!$sitetree) {
386
                return null;
@@ 409-411 (lines=3) @@
406
            if (!$next) {
407
                $parentID = (int) $sitetree->ID;
408
409
                if ($alternatives = static::singleton()->extend('alternateGetByLink', $segment, $parentID)) {
410
                    foreach ($alternatives as $alternative) {
411
                        if ($alternative) {
412
                            $next = $alternative;
413
                        }
414
                    }