src/Hal/Component/Tree/Operator/SizeOfTree.php
public function getDepthOfNode(Node $node)
    {

        $edges = $node->getEdges();

        if (0 === sizeof($edges)) {
            return 0;
        }

        // our tree is not binary : interface can have more than one parent
        $max = 0;
        foreach ($edges as $edge) {

            if ($edge->getFrom() == $node) {
                continue;
            }

            $n = 1 + $this->getDepthOfNode($edge->getFrom());
            if ($n > $max) {
                $max = $n;
            }
        }

        return $max;
    }
public function getDepthOfNode(Node $node)
    {

        $edges = $node->getEdges();

        if (0 === sizeof($edges)) {
            return 0;
        }

        // our tree is not binary : interface can have more than one parent
        $max = 0;
        foreach ($edges as $edge) {

            if ($edge->getFrom() == $node) {
                continue;
            }

            $n = 1 + $this->getDepthOfNode($edge->getFrom());
            if ($n > $max) {
                $max = $n;
            }
        }

        return $max;
    }
Get depth of node

@param Node $node
@return int