def _remove_admin_fields(schema):
    """
    Remove fields that are marked as ca_require_admin=True

    :param schema: schema to remove elements from
    :return: updated schema
    """
    denied_nodes = []
    for node in schema.children:
        if hasattr(node, 'requires_admin') and node.requires_admin:
#        if hasattr(node, 'requires_admin') and node.requires_admin and not has_permission("advanced_fields"):
#            print "Removed node: " + str(node)
            denied_nodes.append(node)
        else:
            if len(node.children) > 0:
                _remove_admin_fields(node)

    for node in denied_nodes:
        schema.children.remove(node)

    return schema