private TreeNode successor(TreeNode predecessorNode) {
        TreeNode successorNode = null;

        if (predecessorNode.left != null) {
            successorNode = predecessorNode.left;
            while (successorNode.right != null) {
                successorNode = successorNode.right;
            }
        } else {
            successorNode = predecessorNode.parent;
            while (successorNode != null && predecessorNode == successorNode.left) {
                predecessorNode = successorNode;
                successorNode = predecessorNode.parent;
            }
        }

        return successorNode;
    }