public static function get_nested_json(array $children, $op = self::OP_AND) {

        // Check $op and work out its type.
        switch($op) {
            case self::OP_AND:
            case self::OP_NOT_OR:
            case self::OP_OR:
            case self::OP_NOT_AND:
                break;
            default:
                throw new \coding_exception('Invalid $op');
        }

        // Do simple tree.
        $result = new \stdClass();
        $result->op = $op;
        $result->c = $children;
        return $result;
    }