public static TResult Result <TSource, TResult>(this IChild <TSource, TResult> child, TSource source, int?firstIndex, int?lastIndex) { var length = child.Count(source); if (length == 0) { return(child.Empty); } var left = firstIndex ?? 0; if (left > length) { return(child.Empty); } if (left < 0) { left = length + left; } if (left < 0) { left = 0; } var right = lastIndex ?? length - 1; if (right >= length) { return(child.Empty); } if (right < 0) { right = length + right; } if (right < 0) { right = 0; } if (left >= right) { return(child.Empty); } return(child.GetChilds(source, left, right)); }