public static void topView(TreeNode root) {
        if (root == null)
            return;
        HashSet<Integer> visited = new HashSet<>();
        Queue<Item> q = new LinkedList<>();
        q.offer(new Item(root, 0));
        while (!q.isEmpty()) {
            Item it = q.poll();
            if (visited.contains(it.h) == false) {
                System.out.println(it.node.val);
                visited.add(it.h);
            }
            if (it.node.left != null)
                q.add(new Item(it.node.left, it.h - 1));
            if (it.node.right != null)
                q.add(new Item(it.node.right, it.h + 1));
        }
    }