[Tex/LaTex] How to position tikz node relative to 2 other nodes

positioningtikz-pgf

Suppose, I have this structure:

enter image description here

Code:

\documentclass{standalone}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{tikz}
\usetikzlibrary{calc,shapes, positioning}
\begin{document}
\def\len{1cm}
\begin{tikzpicture}[node distance = \len, auto]
\tikzset{
    line/.style = {draw},
    block/.style = {rectangle, draw, text centered, minimum height=2em},
}
\node [block] (1-1) {1-1};
\node [block, below = of 1-1] (1-2) {1-2};
\path [line] (1-1) -- (1-2);
\node [block, below right = of 1-2] (2-1) {2-1};
\path [line] (1-2) -| (2-1);
\node [block, right = of 2-1] (3-1) {3-1};
\node [block, dotted] at(3-1|-1-2) (3-2) {3-1};
\path [line] (1-1) -| (3-1);
\end{tikzpicture}
\end{document}

How can I position node 3-1 to the right of node 2-1 and on the same level with 1-2, using calc library? I drew the desired position, using dotted borders.

Please, don't suggest to use matrix.

Update

1 approach is to use above right = of 2-1. It would work for this test case, but if node 1-2 is tall, it wouldn't position 1-3 vertically to the centre of it:

\documentclass{standalone}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{tikz}
\usetikzlibrary{calc,shapes, positioning}
\begin{document}
\def\len{1cm}
\begin{tikzpicture}[node distance = \len, auto]
\tikzset{
    line/.style = {draw},
    block/.style = {rectangle, draw, text centered, minimum height=2em},
}
\node [block] (1-1) {1-1};
\node [block, below = of 1-1, text width = 1cm] (1-2) {text, text, text (!): $\frac{1}{2}$};
\path [line] (1-1) -- (1-2);
\node [block, below right = of 1-2] (2-1) {2-1};
\path [line] (1-2) -| (2-1);
\node [block, above right = of 2-1] (3-1) {3-1};
\path [line] (1-1) -| (3-1);
\end{tikzpicture}
\end{document}

Gives this:

enter image description here

Update 2

@Bordaigorl suggested to use right = 2 of 1-2. But if 2-1 is wide, it will visually overlap with 3-1:

\documentclass{standalone}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{tikz}
\usetikzlibrary{calc,shapes, positioning}
\begin{document}
\def\len{1cm}
\begin{tikzpicture}[node distance = \len, auto]
\tikzset{
    line/.style = {draw},
    block/.style = {rectangle, draw, text centered, minimum height=2em},
}
\node [block] (1-1) {1-1};
\node [block, below = of 1-1, text width = 1cm] (1-2) {text, text, text (!): $\frac{1}{2}$};
\path [line] (1-1) -- (1-2);
\node [block, below right = of 1-2] (2-1) {2-2-2-2-2};
\path [line] (1-2) -| (2-1);
\node [block, right = 2 of 1-2] (3-1) {3-1};
\path [line] (1-1) -| (3-1);
\end{tikzpicture}
\end{document}

enter image description here

Possible solution

I used an extra \coordinate node to the right of 2-1. Is it possible to solve the problem without it?

\documentclass{standalone}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{tikz}
\usetikzlibrary{calc,shapes, positioning}
\begin{document}
\def\len{1cm}
\begin{tikzpicture}[node distance = \len, auto]
\tikzset{
    line/.style = {draw},
    block/.style = {rectangle, draw, text centered, minimum height=2em},
}
\node [block] (1-1) {1-1};
\node [block, below = of 1-1, text width = 1cm] (1-2) {text, text, text (!): $\frac{1}{2}$};
\path [line] (1-1) -- (1-2);
\node [block, below right = of 1-2] (2-1) {2-2-2-2-2};
\path [line] (1-2) -| (2-1);
\node [coordinate, right = of 2-1.east] (3-1) {};
\node [block] at(3-1|-1-2) (3-2) {3-1};
\path [line] (1-1) -| (3-2);
\end{tikzpicture}
\end{document}

enter image description here

Best Answer

You may use right=of 2-1 |- 1-2 (without calc library):

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\def\len{1cm}
\begin{tikzpicture}[node distance = \len, auto]
\tikzset{
    block/.style = {rectangle, draw, text centered, minimum height=2em},
}
\node [block] (1-1) {1-1};
\node [block, below = of 1-1] (1-2) {1-2};
\node [block, below right = of 1-2] (2-1) {2-1};
\node [block,right=of 2-1 |- 1-2] (3-1) {3-1};
\end{tikzpicture}
\end{document}

enter image description here