Validate and return the depth parameter of the recurse directive.

def _get_recurse_directive_depth(field_name, field_directives):
    """Validate and return the depth parameter of the recurse directive."""
    recurse_directive = field_directives['recurse']
    optional_directive = field_directives.get('optional', None)

    if optional_directive:
        raise GraphQLCompilationError(u'Found both @optional and @recurse on '
                                      u'the same vertex field: {}'.format(field_name))

    recurse_args = get_uniquely_named_objects_by_name(recurse_directive.arguments)
    recurse_depth = int(recurse_args['depth'].value.value)
    if recurse_depth < 1:
        raise GraphQLCompilationError(u'Found recurse directive with disallowed depth: '
                                      u'{}'.format(recurse_depth))

    return recurse_depth