Next node of a node in Binary search tree
1

NodeWithParent does not sound funky to me: why not try TreeNode.

2

You can drastically simplify (and rename) the nextNode method:

public static final TreeNode getSuccessorNode(TreeNode node) {
    if (node == null) {
        return null;
    }

    if (node.right != null) {
        return getMinimumNode(node.right);
    }

    TreeNode parent = node.parent;

    while (parent != null &amp;&amp; parent.right == node) {
        node = parent;
        parent = parent.parent;
    }

    return parent;
}


3

Also, it is conventional to start a class name with a capital letter (NextNodeOfANodeInBST). Actually, a better name for you class may be something as BSTUtils or, say, BinarySearchTreeUtils.

4

In your main you have root.parent = null; You don't have to: by default all reference fields in a class are initialized with null.

5

In case your class contains only static methods, it's customary to declare the constructor of such a class as private: it makes no sense to instantiate an object that does nothing in its own right.

Hope that helps.