public void pushDown(Node parent, Node child, Node newParent, String link, String newLink) {
    Node temp = child;
    if (link.toUpperCase().equals("LEFT")) {
      parent.setLeft(child.getRight());
    } else parent.setRight(child.getRight());

    if (newLink.toUpperCase().equals("LEFT")) {
      child.setRight(newParent.getLeft());
      newParent.setLeft(child);
    } else {
      child.setRight(newParent.getRight());
      newParent.setRight(child);
    }
  }
  public void visit(Node parent, Node child, String link) {
    Node nParent = parent;
    Node nChild = child;
    Node newParent = null;
    Expression condition = null;
    ArrayList<Object> operation = null;
    if (nChild == null) return;

    if (nChild.getOptName().equals("SELECT")) {
      operation = (ArrayList<Object>) nChild.getValue();
      condition = (Expression) operation.get(0);
      newParent = nChild.getRight();

      if (newParent.getLeft() != null && checkSchema(nChild.getSchema(), newParent.getSchema())) {
        pushDown(parent, child, child.getRight(), link, "LEFT");
      }
      if (newParent.getRight() != null && checkSchema(nChild.getSchema(), newParent.getSchema())) {
        pushDown(parent, child, child.getRight(), link, "RIGHT");
      }
    }
  }