public boolean areCousins(Node root, int a, int b) {
        Deque<Node> queue = new LinkedList<Node>();
        queue.offerFirst(root);
        int levelSize = 1;
        int tempLevelSize = 1;
        boolean foundFirst = false;
        while (!queue.isEmpty()) {
            levelSize = 0;
            while (tempLevelSize > 0) {
                Node node = queue.pollLast();
                // this is to make sure a and b are not siblings of each other
                // if they are return false since they cant be cousins
                if (checkSameParent(node, a, b)) {
                    return false;
                }
                if (node.data == a || node.data == b) {
                    if (foundFirst) {
                        return true;
                    }
                    foundFirst = true;
                }
                if (node.left != null) {
                    queue.offerFirst(node.left);
                    levelSize++;
                }
                if (node.right != null) {
                    queue.offerFirst(node.right);
                    levelSize++;
                }
                tempLevelSize--;
            }
            if (foundFirst) {
                return false;
            }
            tempLevelSize = levelSize;
        }
        return false;
    }
Little more efficient than other method since this guy does not need
another look up to see if parent is same for found nodes.
src/com/interview/tree/CousinNodes.java