private static void ShiftSelect(this ISelectionService selectionService, ISelectable selectable) { var siblings = selectable.GetSiblings(); //See if there are any non sibinglings that need to be var nonSiblingSelected = selectionService.GetSelected() .Where(s => !siblings.Contains(s)) .ToArray(); foreach (var toUnselect in nonSiblingSelected) { selectionService.Unselect(toUnselect); } //Now, only existing siblings should be selected var selected = selectionService.GetSelected(); //If there are none selected, then select all of the sibings up to this one if (!selected.Any()) { foreach (var sibling in siblings) { selectionService.Select(sibling); if (sibling == selectable) { break; } } } else { //Do a range selection selectionService.SelectBetween(siblings, selectable, selected.LastOrDefault()); } }