<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_unique_directives(ast):
 """Return a dict of directive name to directive object for the given AST node. Any directives that are allowed to exist more than once on any AST node are ignored. For any directives that can only exist up to once, we verify that they are not duplicated raising GraphQLCompilationError in case we find them more than once on the AST node. Args: ast: GraphQL AST node, obtained from the graphql library Returns: dict of string to directive object """

    if not ast.directives:
        return dict()

    result = dict()
    for directive_obj in ast.directives:
        directive_name = directive_obj.name.value
        if directive_name in ALLOWED_DUPLICATED_DIRECTIVES:
            pass  # We don't return these.
        elif directive_name in result:
            raise GraphQLCompilationError(u'Directive was unexpectedly applied twice in the same '
                                          u'location: {} {}'.format(directive_name, ast.directives))
        else:
            result[directive_name] = directive_obj

    return result