Recursive Search in DOM tree

I am working on a project and am currently struggling while working on this recursive search method. The method should recursively search the tree for the first occurrence of a table node, that is, the tag of the node is equal to “table”. Any node can have any number of siblings and any number of children. So far, I have this:

        private TagNode findTablePtr(TagNode root) {
        if(root == null)
            return null; 
        if(root.tag.equals("table")) {
            return root; 
        return findTablePtr(root.firstChild);

However, this does not seem to work properly and I don’t know why. I think the problem is that I am completely ignoring the siblings but I am not completely sure.