def is_cfn_magic(d):
    """
    Given dict `d`, determine if it uses CFN magic (Fn:: functions or Ref)
    This function is used for deep merging CFN templates, we don't treat CFN magic as a regular dictionary
    for merging purposes.

    :rtype: bool
    :param d: dictionary to check
    :return: true if the dictionary uses CFN magic, false if not
    """

    if len(d) != 1:
        return False

    k = d.keys()[0]

    if k == 'Ref' or k.startswith('Fn::') or k.startswith('Rb::'):
        return True

    return False