public static TreeNodeWithParent findNode(TreeNodeWithParent node, TreeNodeWithParent root){
        List<Integer> path = new ArrayList<Integer>();
        while(node.parent != null){
            if(node.parent.left == node){
                path.add(0, 0);
            }else{
                path.add(0, 1);
            }
            node = node.parent;
        }

        for(int n : path){
            if(n == 0){
                root = root.left;
            }else{
                root = root.right;
            }
        }
        return root;
    }