code: protected void checkNode(@Nullable Node node, Token type) throws MalformedException {
      if (node == null) {
        throw new MalformedException(
            "Expected node type " + type + "; found: null", node);
      }
      if (node.getToken() != type) {
        throw new MalformedException(
            "Expected node type " + type + "; found: " + node.getToken(), node);
      }
    }
docs: Checks a node's type.
  
  @throws MalformedException if the node is null or the wrong type