domFilter = (node, parentArr) => {
  if (node.name === undefined) return;
  const newObj = {
    name: node.name,
    children: [],
    id: node.id,
    props: node.props,
    state: node.state,
    methods: node.methods,
    isDOM: node.isDOM,
  };

  if (node.isDOM) {
    node.children.forEach((child) => {
      domFilter(child, parentArr);
    });
  } else {
    parentArr.push(newObj);
    node.children.forEach((child) => {
      domFilter(child, newObj.children);
    });
  }
}
Removes DOM nodes by checking 'isDOM' flag