public static Node nextInorder(Node node) {
		if (node == null)
			return null;

		Node current = node.getRight();

		// If current node has right subtree then the next inorder node is
		// leftmost node in right subtree
		if (current != null) {
			while (current.getLeft() != null)
				current = current.getLeft();
			return current;
		}

		// If current node does not have right subtree then next inorder node
		// will be at upper levels
		current = node;
		// keep going if current is the right child. Stop only if current
		// becomes the left child of a parent
		while (current.getParent() != null && current.isRightChild())
			current = current.getParent();

		if (current.isRoot())
			return null;
		else if (!current.isRightChild())
			return current.getParent();
		else
			return null;
	}