Using LaTeX and TikZ, is it possible to use a Line-To operation in the same command as a distance operation? I would like to draw a rectangle and then create a named node at the midpoint of the upper edge of the rectangle. To do this I am using a Distance Operation to find the center of the Rectangle and then a Line-To Operation to find the upper edge. See below for the MWE code that I think should work, but is not working.

```
\documentclass[11pt]{article}
\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}

\begin{tikzpicture}
\node (A) at (0,0) {};
\node (B) at (10,10) {};
\node [above right] at (A) {A};
\node [below left] at (B) {B};
\draw [draw=black] (B) rectangle (A);
\node at ($(A)!0.5!(B)$ |- B) {Top of Rect [incorrect]};
\node (ABMid) [below] at ($(A)!0.5!(B)$) {Midpoint AB};
\node (rectTop) [above] at (ABMid|-B) {Top of Rect [correct]};
\end{tikzpicture}
\end{document}

```