{
  "type": "project",
  "input": {
    "type": "filter",
    "input": {
      "type": "bgp",
      "patterns": [
        {
          "type": "pattern",
          "termType": "Quad",
          "subject": {
            "termType": "Variable",
            "value": "s"
          },
          "predicate": {
            "termType": "NamedNode",
            "value": "http://www.example.org/p"
          },
          "object": {
            "termType": "Variable",
            "value": "g"
          },
          "graph": {
            "termType": "DefaultGraph",
            "value": ""
          }
        }
      ]
    },
    "expression": {
      "type": "expression",
      "subType": "operator",
      "operator": "if",
      "args": [
        {
          "type": "expression",
          "subType": "term",
          "term": {
            "termType": "Variable",
            "value": "s"
          }
        },
        {
          "type": "expression",
          "subType": "existence",
          "not": false,
          "input": {
            "type": "bgp",
            "patterns": [
              {
                "type": "pattern",
                "termType": "Quad",
                "subject": {
                  "termType": "Variable",
                  "value": "s"
                },
                "predicate": {
                  "termType": "NamedNode",
                  "value": "http://www.example.org/q"
                },
                "object": {
                  "termType": "Variable",
                  "value": "o"
                },
                "graph": {
                  "termType": "NamedNode",
                  "value": "http://www.example.org/a"
                }
              }
            ]
          }
        },
        {
          "type": "expression",
          "subType": "existence",
          "not": false,
          "input": {
            "type": "bgp",
            "patterns": [
              {
                "type": "pattern",
                "termType": "Quad",
                "subject": {
                  "termType": "Variable",
                  "value": "s"
                },
                "predicate": {
                  "termType": "NamedNode",
                  "value": "http://www.example.org/q"
                },
                "object": {
                  "termType": "Variable",
                  "value": "o"
                },
                "graph": {
                  "termType": "NamedNode",
                  "value": "http://www.example.org/b"
                }
              }
            ]
          }
        }
      ]
    }
  },
  "variables": [
    {
      "termType": "Variable",
      "value": "g"
    },
    {
      "termType": "Variable",
      "value": "s"
    }
  ]
}
