public function findStatementForNode(?Name $namespaceName, Name $node): ?Name
    {
        $name = strtolower($node->getFirst());

        $parentNode = ParentNodeAppender::findParent($node);

        if ($parentNode instanceof ClassLike
            && $node instanceof NamedIdentifier
            && $node->getOriginalNode() === $parentNode->name
        ) {
            // The current node can either be the class like name or one of its elements, e.g. extends or implements.
            // In the first case, the node was original an Identifier.

            return null;
        }

        $useStatements = $this->nodes[(string) $namespaceName] ?? [];

        foreach ($useStatements as $use_) {
            foreach ($use_->uses as $useStatement) {
                if (!($useStatement instanceof UseUse)) {
                    continue;
                }

                if ($name === $useStatement->getAlias()->toLowerString()) {
                    if ($this->isFunctionName($node, $parentNode)) {
                        if (Use_::TYPE_FUNCTION === $use_->type) {
                            return $useStatement->name;
                        }

                        continue;
                    }

                    if ($parentNode instanceof ConstFetch && 1 === count($node->parts)) {
                        if (Use_::TYPE_CONSTANT === $use_->type) {
                            return $useStatement->name;
                        }

                        continue;
                    }

                    // Match the alias
                    return $useStatement->name;
                }

                if (null !== $useStatement->alias) {
                    continue;
                }
            }
        }

        return null;
    }