Adding a node to a Binary Search Tree and printing the path to it
if(root != null){
        if(node.data == root.data) return;

        BNode p = root;

        while(p != null){


p cannot be null on the first pass.

Convert your while-loop into a do-while loop.

            }else{
                if(p.left != null){
                    p = p.left;
                }else{
                    p.left = node;
                    node.index = depth;
                    break;
                }
            }


else block containing only a if-elseif chain.

Merge them, like so:

            }else if(p.left != null){
                p = p.left;
            }else{
                p.left = node;
                node.index = depth;
                break;
            }